home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / clisp-li.000 / clisp-li / clisp-1996-07-22 / bindings / linux / linux.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1996-07-11  |  82.7 KB  |  2,486 lines

  1. ;; Foreign functions provided by the Linux C library version 4.5.26
  2. ;; Bruno Haible 5.3.1995
  3.  
  4. (defpackage "LINUX"
  5.   (:nicknames "UNIX")
  6.   (:use "LISP" "FFI")
  7. )
  8.  
  9. (in-package "LINUX")
  10.  
  11. (shadow '(null random abort exit abs acos acosh asin asinh atan atanh cos cosh
  12.           exp floor log sin sinh sqrt tan tanh close read write sleep ftruncate
  13.           truncate open remove make-dir DIR
  14. )        )
  15.  
  16. (export '())
  17.  
  18. ;; This requires linking with NEW_LIBS='linux.o -lm'.
  19.  
  20. ; We want to export all the symbols defined in this file.
  21. (macrolet ((exporting (defining-macro-name)
  22.              (setq defining-macro-name (string-upcase defining-macro-name))
  23.              (shadow defining-macro-name)
  24.              (let ((original-macro-name (intern defining-macro-name "FFI"))
  25.                    (new-macro-name (intern defining-macro-name)))
  26.                `(progn
  27.                   (shadow ',defining-macro-name)
  28.                   (defmacro ,new-macro-name (name &rest more)
  29.                     `(progn
  30.                        (export ',name)
  31.                        (,',original-macro-name ,name ,@more)
  32.                      )
  33.                 ) )
  34.           )) )
  35.   (exporting "defconstant")
  36.   (exporting "defun")
  37.   (exporting "defmacro")
  38.   (exporting "define-modify-macro")
  39.   (exporting "def-c-type")
  40.   (exporting "def-c-enum")
  41.   (exporting "def-c-struct")
  42.   (exporting "def-c-var")
  43.   (exporting "def-c-call-out")
  44. )
  45.  
  46. (def-c-type longlong sint64)
  47. (def-c-type ulonglong uint64)
  48. (define-modify-macro orf () logior)
  49. (define-modify-macro andf () logand)
  50.  
  51. ; =========================== <sys/types.h> ===================================
  52.  
  53. (c-lines "#include <sys/types.h>~%")
  54.  
  55. ; --------------------------- <asm/types.h> -----------------------------------
  56.  
  57. (def-c-type size_t uint)
  58. (def-c-type ssize_t int)
  59. (def-c-type ptrdiff_t int)
  60. (def-c-type s8 sint8)
  61. (def-c-type u8 uint8)
  62. (def-c-type s16 sint16)
  63. (def-c-type u16 uint16)
  64. (def-c-type s32 sint32)
  65. (def-c-type u32 uint32)
  66. (def-c-type s64 sint64)
  67. (def-c-type u64 uint64)
  68.  
  69. ; --------------------------- <linux/types.h> ---------------------------------
  70.  
  71. (def-c-type time_t long)
  72.  
  73. (def-c-type clock_t long)
  74.  
  75. (defconstant null 0)
  76.  
  77. (def-c-type pid_t int)
  78. (def-c-type uid_t ushort)
  79. (def-c-type gid_t ushort)
  80. (def-c-type dev_t ushort)
  81. (def-c-type ino_t ulong)
  82. (def-c-type mode_t ushort)
  83. (def-c-type umode_t ushort)
  84. (def-c-type nlink_t ushort)
  85. (def-c-type daddr_t int)
  86. (def-c-type off_t long)
  87.  
  88. (def-c-type loff_t longlong)
  89.  
  90. ;(def-c-type u_char uchar)
  91. ;(def-c-type u_short ushort)
  92. ;(def-c-type u_int uint)
  93. ;(def-c-type u_long ulong)
  94.  
  95. ;(def-c-type unchar uchar)
  96. ;(def-c-type unshort ushort)
  97.  
  98. (def-c-type caddr_t c-pointer)
  99.  
  100. (def-c-type cc_t uchar)
  101. (def-c-type speed_t uint)
  102. (def-c-type tcflag_t ulong)
  103.  
  104. (def-c-type fd_set (c-struct vector (fds_bits (c-array ulong 8))))
  105. (defmacro fd_set (fd fdset)
  106.   (let ((i (gensym)) (j (gensym)))
  107.     `(MULTIPLE-VALUE-BIND (,i ,j) (FLOOR ,fd ,(bitsizeof 'ulong))
  108.        (ORF (AREF ,fdset ,i) (ASH 1 ,j))
  109.      )
  110. ) )
  111. (defmacro fd_clr (fd fdset)
  112.   (let ((i (gensym)) (j (gensym)))
  113.     `(MULTIPLE-VALUE-BIND (,i ,j) (FLOOR ,fd ,(bitsizeof 'ulong))
  114.        (ANDF (AREF ,fdset ,i) (LOGNOT (ASH 1 ,j)))
  115.      )
  116. ) )
  117. (defun fd_isset (fd fdset)
  118.   (multiple-value-bind (i j) (floor fd (load-time-value (bitsizeof 'ulong)))
  119.     (logbitp j (aref fdset i))
  120. ) )
  121. (defun fd_zero (fdset)
  122.   (fill fdset 0)
  123. )
  124.  
  125. #| ;; Present in libc-4, but not libc-5.
  126. (def-c-struct ustat
  127.   (f_tfree daddr_t)
  128.   (f_tinode ino_t)
  129.   (f_fname (c-array character 6))
  130.   (f_fpack (c-array character 6))
  131. )
  132. |#
  133.  
  134. ; --------------------------- <sys/types.h> -----------------------------------
  135.  
  136. (def-c-type fd_mask ulong)
  137.  
  138. ; =========================== <_G_config.h> ===================================
  139.  
  140. (defconstant c_lib_version "4.5.26")
  141. (defconstant c_lib_version_major 4)
  142. (defconstant c_lib_version_minor 5)
  143. (defconstant c_lib_version_subminor 26)
  144.  
  145. (defconstant g_lib_version "0.63")
  146. (def-c-type _G_clock_t long)
  147. (def-c-type _G_dev_t ushort)
  148. (def-c-type _G_fpos_t long)
  149. (def-c-type _G_gid_t ushort)
  150. (def-c-type _G_ino_t ulong)
  151. (def-c-type _G_mode_t ushort)
  152. (def-c-type _G_nlink_t ushort)
  153. (def-c-type _G_off_t long)
  154. (def-c-type _G_pid_t int)
  155. (def-c-type _G_ptrdiff_t int)
  156. (def-c-type _G_sigset_t uint)
  157. (def-c-type _G_size_t uint)
  158. (def-c-type _G_time_t long)
  159. (def-c-type _G_uid_t ushort)
  160. (def-c-type _G_wchar_t long)
  161. (def-c-type _G_int32_t sint32)
  162. (def-c-type _G_uint32_t uint32)
  163. (def-c-type _G_ssize_t int)
  164. (def-c-type _G_va_list c-pointer)
  165. (def-c-type _G_signal_return_type nil)
  166. (def-c-type _G_sprintf_return_type int)
  167. (defconstant _G_BUFSIZ 1024)
  168. (defconstant _G_FOPEN_MAX 256)
  169. (defconstant _G_FILENAME_MAX 1024)
  170. (defconstant _G_NULL 0)
  171.  
  172. ; ============================ <ansidecl.h> ===================================
  173.  
  174. ; ============================ <sys/cdefs.h> ==================================
  175.  
  176. ; ============================ <features.h> ===================================
  177.  
  178. ; ============================== <stddef.h> ===================================
  179.  
  180. (def-c-type wchar_t int)
  181.  
  182. ; ============================== <errno.h> ====================================
  183.  
  184. ; --------------------------- <linux/errno.h> ---------------------------------
  185.  
  186. (defconstant    EPERM            1)     ; Operation not permitted
  187. (defconstant    ENOENT           2)     ; No such file or directory
  188. (defconstant    ESRCH            3)     ; No such process
  189. (defconstant    EINTR            4)     ; Interrupted system call
  190. (defconstant    EIO              5)     ; I/O error
  191. (defconstant    ENXIO            6)     ; No such device or address
  192. (defconstant    E2BIG            7)     ; Arg list too long
  193. (defconstant    ENOEXEC          8)     ; Exec format error
  194. (defconstant    EBADF            9)     ; Bad file number
  195. (defconstant    ECHILD          10)     ; No child processes
  196. (defconstant    EAGAIN          11)     ; Try again
  197. (defconstant    ENOMEM          12)     ; Out of memory
  198. (defconstant    EACCES          13)     ; Permission denied
  199. (defconstant    EFAULT          14)     ; Bad address
  200. (defconstant    ENOTBLK         15)     ; Block device required
  201. (defconstant    EBUSY           16)     ; Device or resource busy
  202. (defconstant    EEXIST          17)     ; File exists
  203. (defconstant    EXDEV           18)     ; Cross-device link
  204. (defconstant    ENODEV          19)     ; No such device
  205. (defconstant    ENOTDIR         20)     ; Not a directory
  206. (defconstant    EISDIR          21)     ; Is a directory
  207. (defconstant    EINVAL          22)     ; Invalid argument
  208. (defconstant    ENFILE          23)     ; File table overflow
  209. (defconstant    EMFILE          24)     ; Too many open files
  210. (defconstant    ENOTTY          25)     ; Not a typewriter
  211. (defconstant    ETXTBSY         26)     ; Text file busy
  212. (defconstant    EFBIG           27)     ; File too large
  213. (defconstant    ENOSPC          28)     ; No space left on device
  214. (defconstant    ESPIPE          29)     ; Illegal seek
  215. (defconstant    EROFS           30)     ; Read-only file system
  216. (defconstant    EMLINK          31)     ; Too many links
  217. (defconstant    EPIPE           32)     ; Broken pipe
  218. (defconstant    EDOM            33)     ; Math argument out of domain of func
  219. (defconstant    ERANGE          34)     ; Math result not representable
  220. (defconstant    EDEADLK         35)     ; Resource deadlock would occur
  221. (defconstant    ENAMETOOLONG    36)     ; File name too long
  222. (defconstant    ENOLCK          37)     ; No record locks available
  223. (defconstant    ENOSYS          38)     ; Function not implemented
  224. (defconstant    ENOTEMPTY       39)     ; Directory not empty
  225. (defconstant    ELOOP           40)     ; Too many symbolic links encountered
  226. (defconstant    EWOULDBLOCK     EAGAIN) ; Operation would block
  227. (defconstant    ENOMSG          42)     ; No message of desired type
  228. (defconstant    EIDRM           43)     ; Identifier removed
  229. (defconstant    ECHRNG          44)     ; Channel number out of range
  230. (defconstant    EL2NSYNC        45)     ; Level 2 not synchronized
  231. (defconstant    EL3HLT          46)     ; Level 3 halted
  232. (defconstant    EL3RST          47)     ; Level 3 reset
  233. (defconstant    ELNRNG          48)     ; Link number out of range
  234. (defconstant    EUNATCH         49)     ; Protocol driver not attached
  235. (defconstant    ENOCSI          50)     ; No CSI structure available
  236. (defconstant    EL2HLT          51)     ; Level 2 halted
  237. (defconstant    EBADE           52)     ; Invalid exchange
  238. (defconstant    EBADR           53)     ; Invalid request descriptor
  239. (defconstant    EXFULL          54)     ; Exchange full
  240. (defconstant    ENOANO          55)     ; No anode
  241. (defconstant    EBADRQC         56)     ; Invalid request code
  242. (defconstant    EBADSLT         57)     ; Invalid slot
  243. (defconstant    EDEADLOCK       58)     ; File locking deadlock error
  244. (defconstant    EBFONT          59)     ; Bad font file format
  245. (defconstant    ENOSTR          60)     ; Device not a stream
  246. (defconstant    ENODATA         61)     ; No data available
  247. (defconstant    ETIME           62)     ; Timer expired
  248. (defconstant    ENOSR           63)     ; Out of streams resources
  249. (defconstant    ENONET          64)     ; Machine is not on the network
  250. (defconstant    ENOPKG          65)     ; Package not installed
  251. (defconstant    EREMOTE         66)     ; Object is remote
  252. (defconstant    ENOLINK         67)     ; Link has been severed
  253. (defconstant    EADV            68)     ; Advertise error
  254. (defconstant    ESRMNT          69)     ; Srmount error
  255. (defconstant    ECOMM           70)     ; Communication error on send
  256. (defconstant    EPROTO          71)     ; Protocol error
  257. (defconstant    EMULTIHOP       72)     ; Multihop attempted
  258. (defconstant    EDOTDOT         73)     ; RFS specific error
  259. (defconstant    EBADMSG         74)     ; Not a data message
  260. (defconstant    EOVERFLOW       75)     ; Value too large for defined data type
  261. (defconstant    ENOTUNIQ        76)     ; Name not unique on network
  262. (defconstant    EBADFD          77)     ; File descriptor in bad state
  263. (defconstant    EREMCHG         78)     ; Remote address changed
  264. (defconstant    ELIBACC         79)     ; Can not access a needed shared library
  265. (defconstant    ELIBBAD         80)     ; Accessing a corrupted shared library
  266. (defconstant    ELIBSCN         81)     ; .lib section in a.out corrupted
  267. (defconstant    ELIBMAX         82)     ; Attempting to link in too many shared libraries
  268. (defconstant    ELIBEXEC        83)     ; Cannot exec a shared library directly
  269. (defconstant    EILSEQ          84)     ; Illegal byte sequence
  270. (defconstant    ERESTART        85)     ; Interrupted system call should be restarted
  271. (defconstant    ESTRPIPE        86)     ; Streams pipe error
  272. (defconstant    EUSERS          87)     ; Too many users
  273. (defconstant    ENOTSOCK        88)     ; Socket operation on non-socket
  274. (defconstant    EDESTADDRREQ    89)     ; Destination address required
  275. (defconstant    EMSGSIZE        90)     ; Message too long
  276. (defconstant    EPROTOTYPE      91)     ; Protocol wrong type for socket
  277. (defconstant    ENOPROTOOPT     92)     ; Protocol not available
  278. (defconstant    EPROTONOSUPPORT 93)     ; Protocol not supported
  279. (defconstant    ESOCKTNOSUPPORT 94)     ; Socket type not supported
  280. (defconstant    EOPNOTSUPP      95)     ; Operation not supported on transport endpoint
  281. (defconstant    EPFNOSUPPORT    96)     ; Protocol family not supported
  282. (defconstant    EAFNOSUPPORT    97)     ; Address family not supported by protocol
  283. (defconstant    EADDRINUSE      98)     ; Address already in use
  284. (defconstant    EADDRNOTAVAIL   99)     ; Cannot assign requested address
  285. (defconstant    ENETDOWN        100)    ; Network is down
  286. (defconstant    ENETUNREACH     101)    ; Network is unreachable
  287. (defconstant    ENETRESET       102)    ; Network dropped connection because of reset
  288. (defconstant    ECONNABORTED    103)    ; Software caused connection abort
  289. (defconstant    ECONNRESET      104)    ; Connection reset by peer
  290. (defconstant    ENOBUFS         105)    ; No buffer space available
  291. (defconstant    EISCONN         106)    ; Transport endpoint is already connected
  292. (defconstant    ENOTCONN        107)    ; Transport endpoint is not connected
  293. (defconstant    ESHUTDOWN       108)    ; Cannot send after transport endpoint shutdown
  294. (defconstant    ETOOMANYREFS    109)    ; Too many references: cannot splice
  295. (defconstant    ETIMEDOUT       110)    ; Connection timed out
  296. (defconstant    ECONNREFUSED    111)    ; Connection refused
  297. (defconstant    EHOSTDOWN       112)    ; Host is down
  298. (defconstant    EHOSTUNREACH    113)    ; No route to host
  299. (defconstant    EALREADY        114)    ; Operation already in progress
  300. (defconstant    EINPROGRESS     115)    ; Operation now in progress
  301. (defconstant    ESTALE          116)    ; Stale NFS file handle
  302. (defconstant    EUCLEAN         117)    ; Structure needs cleaning
  303. (defconstant    ENOTNAM         118)    ; Not a XENIX named type file
  304. (defconstant    ENAVAIL         119)    ; No XENIX semaphores available
  305. (defconstant    EISNAM          120)    ; Is a named type file
  306. (defconstant    EREMOTEIO       121)    ; Remote I/O error
  307. (defconstant    EDQUOT          122)    ; Quota exceeded
  308.  
  309. ; ------------------------------ <errno.h> ------------------------------------
  310.  
  311. (def-c-var sys_nerr (:type int) (:read-only t))
  312. (def-c-var sys_errlist (:type (c-array c-string 122)) (:read-only t))
  313.  
  314. (def-c-var errno (:type int))
  315.  
  316. (def-c-call-out perror (:arguments (s c-string))
  317.                        (:return-type nil)
  318. )
  319. (def-c-call-out strerror (:arguments (errno int))
  320.                          (:return-type c-string :none)
  321. )
  322.  
  323. ; ============================ <sys/errno.h> ==================================
  324.  
  325. ; ============================== <varargs.h> ==================================
  326. ; C compiler dependent
  327.  
  328. ; ============================== <stdarg.h> ===================================
  329. ; C compiler dependent
  330.  
  331. ; ============================== <stdlib.h> ===================================
  332.  
  333. (def-c-struct div_t
  334.   (quot int)
  335.   (rem int)
  336. )
  337. (def-c-struct ldiv_t
  338.   (quot long)
  339.   (rem long)
  340. )
  341.  
  342. (defconstant rand-max 2147483647)
  343.  
  344. (defconstant EXIT_FAILURE 1)
  345. (defconstant EXIT_SUCCESS 1)
  346.  
  347. (defconstant MB_CUR_MAX 1)
  348.  
  349. (def-c-call-out atof (:arguments (nptr c-string))
  350.                      (:return-type double-float)
  351. )
  352. (def-c-call-out atoi (:arguments (nptr c-string))
  353.                      (:return-type int)
  354. )
  355. (def-c-call-out atol (:arguments (nptr c-string))
  356.                      (:return-type long)
  357. )
  358. (def-c-call-out strtod (:arguments (nptr c-string)
  359.                                    (endptr (c-ptr c-string) :out)
  360.                        )
  361.                        (:return-type double-float)
  362. )
  363. (def-c-call-out strtol (:arguments (nptr c-string)
  364.                                    (endptr (c-ptr c-string) :out)
  365.                                    (base int)
  366.                        )
  367.                        (:return-type long)
  368. )
  369. (def-c-call-out strtoul (:arguments (nptr c-string)
  370.                                     (endptr (c-ptr c-string) :out)
  371.                                     (base int)
  372.                         )
  373.                         (:return-type ulong)
  374. )
  375.  
  376. (def-c-call-out rand (:arguments)
  377.                      (:return-type int)
  378. )
  379. (def-c-call-out srand (:arguments (seed uint))
  380.                       (:return-type nil)
  381. )
  382.  
  383. (def-c-call-out random (:arguments)
  384.                        (:return-type long)
  385. )
  386. (def-c-call-out srandom (:arguments (seed uint))
  387.                         (:return-type nil)
  388. )
  389. (def-c-call-out initstate (:arguments (seed uint) (statebuf c-pointer) (statelen size_t))
  390.                           (:return-type c-pointer)
  391. )
  392. (def-c-call-out setstate (:arguments (statebuf c-pointer))
  393.                          (:return-type c-pointer)
  394. )
  395.  
  396. (def-c-call-out malloc (:arguments (size size_t))
  397.                        (:return-type c-pointer)
  398. )
  399. (def-c-call-out realloc (:arguments (ptr c-pointer) (size size_t))
  400.                         (:return-type c-pointer)
  401. )
  402. (def-c-call-out calloc (:arguments (nmemb size_t) (size size_t))
  403.                        (:return-type c-pointer)
  404. )
  405. (def-c-call-out free (:arguments (ptr c-pointer))
  406.                      (:return-type nil)
  407. )
  408. (def-c-call-out cfree (:arguments (ptr c-pointer))
  409.                       (:return-type nil)
  410. )
  411. (def-c-call-out valloc (:arguments (size size_t))
  412.                        (:return-type c-pointer)
  413. )
  414.  
  415. (def-c-call-out abort (:arguments)
  416.                       (:return-type nil)
  417. )
  418.  
  419. (def-c-call-out atexit (:arguments (func (c-function)))
  420.                        (:return-type int)
  421. )
  422.  
  423. (def-c-call-out on_exit (:arguments (func (c-function (:arguments (status int) (arg c-pointer)))) (arg c-pointer))
  424.                         (:return-type int)
  425. )
  426.  
  427. (def-c-call-out exit (:arguments (status int))
  428.                      (:return-type nil)
  429. )
  430.  
  431. (def-c-call-out getenv (:arguments (name c-string))
  432.                        (:return-type c-string)
  433. )
  434.  
  435. (def-c-call-out putenv (:arguments (string c-string :in :malloc-free))
  436.                        (:return-type int)
  437. )
  438.  
  439. (def-c-call-out system (:arguments (command c-string))
  440.                        (:return-type int)
  441. )
  442. (def-c-call-out system? (:arguments (null c-string))
  443.                         (:return-type boolean)
  444.                         (:name "system")
  445. )
  446.  
  447. (def-c-type comparison_fn_t (c-function (:arguments (p1 c-pointer) (p2 c-pointer))
  448.                                         (:return-type int)
  449. )                           )
  450.  
  451. (def-c-call-out bsearch (:arguments (key c-pointer) (base c-pointer) (nmemb size_t) (size size_t) (compar comparison_fn_t))
  452.                         (:return-type c-pointer)
  453. )
  454.  
  455. (def-c-call-out qsort (:arguments (base c-pointer) (nmemb size_t) (size size_t) (compar comparison_fn_t))
  456.                       (:return-type nil)
  457. )
  458.  
  459. (def-c-call-out abs (:arguments (x int))
  460.                     (:return-type int)
  461. )
  462. (def-c-call-out labs (:arguments (x long))
  463.                      (:return-type long)
  464. )
  465.  
  466. (def-c-call-out div (:arguments (numer int) (denom int))
  467.                     (:return-type div_t)
  468. )
  469. (def-c-call-out ldiv (:arguments (numer long) (denom long))
  470.                      (:return-type ldiv_t)
  471. )
  472.  
  473. (def-c-call-out mblen (:arguments (s c-string) (n size_t))
  474.                       (:return-type int)
  475. )
  476. (def-c-call-out mbtowc (:arguments (pwc (c-ptr wchar_t) :out) (s c-string) (n size_t))
  477.                        (:return-type int)
  478. )
  479. ;(def-c-call-out wctomb (:arguments (s (c-ptr (c-array character 10)) :out) (wchar wchar_t)) ; ??
  480. ;                       (:return-type int)
  481. ;)
  482.  
  483. ;(def-c-call-out mbstowcs (:arguments (pwcs (c-ptr (c-array wchar_t)) :out) (s c-string) (n size_t)) ; ??
  484. ;                         (:return-type size_t)
  485. ;)
  486. ;(def-c-call-out wcstombs (:arguments (s c-string :out) (pwcs (c-ptr (c-array wchar_t))) (n size_t)) ; ??
  487. ;                         (:return-type size_t)
  488. ;)
  489.  
  490. (def-c-var environ (:type (c-array-ptr c-string)) (:read-only t))
  491.  
  492. ;(def-c-call-out memalign (:arguments (alignment size_t) (size size_t))
  493. ;                         (:return-type c-pointer)
  494. ;) ; non-existent
  495. (def-c-call-out valloc (:arguments (size size_t))
  496.                        (:return-type c-pointer)
  497. )
  498.  
  499. (def-c-call-out ecvt (:arguments (value double-float) (ndigit size_t) (decpt (c-ptr int) :out) (sign (c-ptr int) :out))
  500.                      (:return-type c-string :none)
  501. )
  502. (def-c-call-out fcvt (:arguments (value double-float) (ndigit size_t) (decpt (c-ptr int) :out) (sign (c-ptr int) :out))
  503.                      (:return-type c-string :none)
  504. )
  505. ;(def-c-call-out gcvt (:arguments (value double-float) (ndigit size_t) (buf (c-array character) :out)) ; ??
  506. ;                (:return-type c-string)
  507. ;)
  508. ;(def-c-call-out dtoa (:arguments (d double-float) (mode int) (ndigits int) (decpt (c-ptr int) :out) (sign (c-ptr int) :out) (rve (c-array character) :out)) ; ??
  509. ;                (:return-type c-string)
  510. ;)
  511.  
  512. (def-c-call-out drand48 (:arguments)
  513.                         (:return-type double-float)
  514. )
  515. (def-c-call-out erand48 (:arguments (xsubi (c-ptr (c-array ushort 3))))
  516.                         (:return-type double-float)
  517. )
  518. (def-c-call-out lrand48 (:arguments)
  519.                         (:return-type long)
  520. )
  521. (def-c-call-out nrand48 (:arguments (xsubi (c-ptr (c-array ushort 3))))
  522.                         (:return-type long)
  523. )
  524. (def-c-call-out mrand48 (:arguments)
  525.                         (:return-type long)
  526. )
  527. (def-c-call-out jrand48 (:arguments (xsubi (c-ptr (c-array ushort 3))))
  528.                         (:return-type long)
  529. )
  530. (def-c-call-out srand48 (:arguments (seedval long))
  531.                         (:return-type nil)
  532. )
  533. (def-c-call-out seed48 (:arguments (seed16v (c-ptr (c-array ushort 3))))
  534.                        (:return-type (c-ptr (c-array ushort 3)) :none)
  535. )
  536. (def-c-call-out lcong48 (:arguments (param (c-ptr (c-array ushort 7))))
  537.                         (:return-type nil)
  538. )
  539.  
  540. (def-c-call-out setenv (:arguments (name c-string) (value c-string) (overwrite boolean))
  541.                        (:return-type int)
  542. )
  543. (def-c-call-out unsetenv (:arguments (name c-string))
  544.                          (:return-type int)
  545. )
  546.  
  547. (def-c-struct qelem
  548.   (q_forw (c-ptr qelem))
  549.   (q_back (c-ptr qelem))
  550. )
  551.  
  552. (def-c-call-out insque (:arguments (elem qelem) (prev qelem))
  553.                        (:return-type nil)
  554. )
  555. (def-c-call-out remque (:arguments (elem qelem))
  556.                        (:return-type nil)
  557. )
  558.  
  559. ; ============================== <ctype.h> ====================================
  560.  
  561. (def-c-call-out isalnum (:arguments (c int))
  562.                         (:return-type boolean)
  563. )
  564. (def-c-call-out isalpha (:arguments (c int))
  565.                         (:return-type boolean)
  566. )
  567. (def-c-call-out iscntrl (:arguments (c int))
  568.                         (:return-type boolean)
  569. )
  570. (def-c-call-out isdigit (:arguments (c int))
  571.                         (:return-type boolean)
  572. )
  573. (def-c-call-out islower (:arguments (c int))
  574.                         (:return-type boolean)
  575. )
  576. (def-c-call-out isgraph (:arguments (c int))
  577.                         (:return-type boolean)
  578. )
  579. (def-c-call-out isprint (:arguments (c int))
  580.                         (:return-type boolean)
  581. )
  582. (def-c-call-out ispunct (:arguments (c int))
  583.                         (:return-type boolean)
  584. )
  585. (def-c-call-out isspace (:arguments (c int))
  586.                         (:return-type boolean)
  587. )
  588. (def-c-call-out isupper (:arguments (c int))
  589.                         (:return-type boolean)
  590. )
  591. (def-c-call-out isxdigit (:arguments (c int))
  592.                          (:return-type boolean)
  593. )
  594. (def-c-call-out isblank (:arguments (c int))
  595.                         (:return-type boolean)
  596. )
  597.  
  598. (def-c-call-out tolower (:arguments (c int))
  599.                         (:return-type int)
  600. )
  601. (def-c-call-out toupper (:arguments (c int))
  602.                         (:return-type int)
  603. )
  604.  
  605. (def-c-call-out isascii (:arguments (c int))
  606.                         (:return-type boolean)
  607. )
  608. (def-c-call-out toascii (:arguments (c int))
  609.                         (:return-type int)
  610. )
  611.  
  612. (def-c-call-out _tolower (:arguments (c int))
  613.                          (:return-type int)
  614. )
  615. (def-c-call-out _toupper (:arguments (c int))
  616.                          (:return-type int)
  617. )
  618.  
  619. ; ============================== <float.h> ====================================
  620.  
  621. (defconstant FLT_RADIX 2)
  622. (defconstant FLT_MANT_DIG 24)
  623. (defconstant FLT_DIG 6)
  624. (defconstant FLT_ROUNDS 1)
  625. (defconstant FLT_EPSILON 1.19209290f-07)
  626. (defconstant FLT_MIN_EXP -125)
  627. (defconstant FLT_MIN 1.17549435f-38)
  628. (defconstant FLT_MIN_10_EXP -37)
  629. (defconstant FLT_MAX_EXP 128)
  630. (defconstant FLT_MAX 3.40282347f+38)
  631. (defconstant FLT_MAX_10_EXP 38)
  632.  
  633. (defconstant DBL_MANT_DIG 53)
  634. (defconstant DBL_DIG 15)
  635. (defconstant DBL_EPSILON 2.2204460492503131d-16)
  636. (defconstant DBL_MIN_EXP -1021)
  637. (defconstant DBL_MIN 2.2250738585072014d-308)
  638. (defconstant DBL_MIN_10_EXP -307)
  639. (defconstant DBL_MAX_EXP 1024)
  640. (defconstant DBL_MAX 1.7976931348623157d+308)
  641. (defconstant DBL_MAX_10_EXP 308)
  642.  
  643. (defconstant LDBL_MANT_DIG 64)
  644. (defconstant LDBL_DIG 18)
  645. (defconstant LDBL_EPSILON 1.084202172485504434L-19) ; ??
  646. (defconstant LDBL_MIN_EXP -16381)
  647. (defconstant LDBL_MIN 3.3621031431120935063L-4932) ; ??
  648. (defconstant LDBL_MIN_10_EXP -4931)
  649. (defconstant LDBL_MAX_EXP 16384)
  650. (defconstant LDBL_MAX 1.189731495357231765L4932) ; ??
  651. (defconstant LDBL_MAX_10_EXP 4932)
  652.  
  653. ; ============================== <limits.h> ===================================
  654.  
  655. (defconstant CHAR_BIT 8)
  656. (defconstant MB_LEN_MAX 1)
  657. (defconstant SCHAR_MIN -128)
  658. (defconstant SCHAR_MAX 127)
  659. (defconstant UCHAR_MAX 255)
  660. (defconstant CHAR_MIN -128)
  661. (defconstant CHAR_MAX 127)
  662. (defconstant SHRT_MIN -32768)
  663. (defconstant SHRT_MAX 32767)
  664. (defconstant USHRT_MAX 65535)
  665. (defconstant INT_MIN -2147483648)
  666. (defconstant INT_MAX 2147483647)
  667. (defconstant UINT_MAX 4294967295)
  668. (defconstant LONG_MIN -2147483648)
  669. (defconstant LONG_MAX 2147483647)
  670. (defconstant ULONG_MAX 4294967295)
  671. (defconstant LONG_LONG_MIN -9223372036854775808)
  672. (defconstant LONG_LONG_MAX 9223372036854775807)
  673. (defconstant ULONG_LONG_MAX 18446744073709551615)
  674.  
  675. ; ============================== <values.h> ===================================
  676.  
  677. (defconstant CHARBITS (bitsizeof 'char))
  678. (defconstant SHORTBITS (bitsizeof 'short))
  679. (defconstant INTBITS (bitsizeof 'int))
  680. (defconstant LONGBITS (bitsizeof 'long))
  681. (defconstant PTRBITS (bitsizeof 'c-pointer))
  682. (defconstant DOUBLEBITS (bitsizeof 'double-float))
  683. (defconstant FLOATBITS (bitsizeof 'single-float))
  684. (defconstant MINSHORT -32768)
  685. (defconstant MININT -2147483648)
  686. (defconstant MINLONG -2147483648)
  687. (defconstant MAXSHORT 32767)
  688. (defconstant MAXINT 2147483647)
  689. (defconstant MAXLONG 2147483647)
  690. (defconstant MAXDOUBLE 1.79769313486231570d+308)
  691. (defconstant MAXFLOAT 3.40282347f+38)
  692. (defconstant MINDOUBLE 4.94065645841246544L-324)
  693. (defconstant MINFLOAT 1.40129846d-45)
  694. (defconstant _IEEE 1)
  695. (defconstant _DEXPLEN 11)
  696. (defconstant _FEXPLEN 8)
  697. (defconstant _HIDDENBIT 1)
  698. (defconstant DMAXEXP (+ (1- (ash 1 _DEXPLEN)) -1 _IEEE))
  699. (defconstant FMAXEXP (+ (1- (ash 1 _FEXPLEN)) -1 _IEEE))
  700. (defconstant DMINEXP (- DMAXEXP))
  701. (defconstant FMINEXP (- FMAXEXP))
  702. (defconstant DSIGNIF (+ DOUBLEBITS (- _DEXPLEN) _HIDDENBIT -1))
  703. (defconstant FSIGNIF (+ FLOATBITS (- _FEXPLEN) _HIDDENBIT -1))
  704. (defconstant DMAXPOWTWO (coerce (1- (ash 1 DSIGNIF)) 'double-float))
  705. (defconstant FMAXPOWTWO (coerce (1- (ash 1 FSIGNIF)) 'single-float))
  706.  
  707. ; =============================== <math.h> ====================================
  708.  
  709. (def-c-call-out acos (:arguments (x double-float))
  710.                      (:return-type double-float)
  711. )
  712. (def-c-call-out acosh (:arguments (x double-float))
  713.                       (:return-type double-float)
  714. )
  715. (def-c-call-out asin (:arguments (x double-float))
  716.                      (:return-type double-float)
  717. )
  718. (def-c-call-out asinh (:arguments (x double-float))
  719.                       (:return-type double-float)
  720. )
  721. (def-c-call-out atan (:arguments (x double-float))
  722.                      (:return-type double-float)
  723. )
  724. (def-c-call-out atan2 (:arguments (x double-float) (y double-float))
  725.                       (:return-type double-float)
  726. )
  727. (def-c-call-out atanh (:arguments (x double-float))
  728.                       (:return-type double-float)
  729. )
  730. (def-c-call-out ceil (:arguments (x double-float))
  731.                      (:return-type double-float)
  732. )
  733. (def-c-call-out cos (:arguments (x double-float))
  734.                     (:return-type double-float)
  735. )
  736. (def-c-call-out cosh (:arguments (x double-float))
  737.                      (:return-type double-float)
  738. )
  739. (def-c-call-out drem (:arguments (x double-float) (y double-float))
  740.                      (:return-type double-float)
  741. )
  742. (def-c-call-out exp (:arguments (x double-float))
  743.                     (:return-type double-float)
  744. )
  745. (def-c-call-out fabs (:arguments (x double-float))
  746.                      (:return-type double-float)
  747. )
  748. (def-c-call-out floor (:arguments (x double-float))
  749.                       (:return-type double-float)
  750. )
  751. (def-c-call-out fmod (:arguments (x double-float) (y double-float))
  752.                      (:return-type double-float)
  753. )
  754. (def-c-call-out hypot (:arguments (x double-float) (y double-float))
  755.                       (:return-type double-float)
  756. )
  757. (def-c-call-out frexp (:arguments (x double-float) (exp (c-ptr int) :out))
  758.                       (:return-type double-float)
  759. )
  760. (def-c-call-out ldexp (:arguments (x double-float) (exp int))
  761.                       (:return-type double-float)
  762. )
  763. (def-c-call-out log (:arguments (x double-float))
  764.                     (:return-type double-float)
  765. )
  766. (def-c-call-out log10 (:arguments (x double-float))
  767.                       (:return-type double-float)
  768. )
  769. (def-c-call-out modf (:arguments (x double-float) (iptr (c-ptr double-float) :out))
  770.                      (:return-type double-float)
  771. )
  772. (def-c-call-out pow (:arguments (x double-float) (y double-float))
  773.                     (:return-type double-float)
  774. )
  775. (def-c-call-out pow2 (:arguments (x double-float))
  776.                      (:return-type double-float)
  777. )
  778. (def-c-call-out pow10 (:arguments (x double-float))
  779.                       (:return-type double-float)
  780. )
  781. (def-c-call-out sin (:arguments (x double-float))
  782.                     (:return-type double-float)
  783. )
  784. (def-c-call-out sinh (:arguments (x double-float))
  785.                      (:return-type double-float)
  786. )
  787. (def-c-call-out sqrt (:arguments (x double-float))
  788.                      (:return-type double-float)
  789. )
  790. (def-c-call-out tan (:arguments (x double-float))
  791.                     (:return-type double-float)
  792. )
  793. (def-c-call-out tanh (:arguments (x double-float))
  794.                      (:return-type double-float)
  795. )
  796. (def-c-call-out erf (:arguments (x double-float))
  797.                     (:return-type double-float)
  798. )
  799. (def-c-call-out erfc (:arguments (x double-float))
  800.                      (:return-type double-float)
  801. )
  802. (def-c-call-out j0 (:arguments (x double-float))
  803.                    (:return-type double-float)
  804. )
  805. (def-c-call-out j1 (:arguments (x double-float))
  806.                    (:return-type double-float)
  807. )
  808. (def-c-call-out jn (:arguments (n int) (x double-float))
  809.                    (:return-type double-float)
  810. )
  811. (def-c-call-out lgamma (:arguments (x double-float))
  812.                        (:return-type double-float)
  813. )
  814. (def-c-call-out y0 (:arguments (x double-float))
  815.                    (:return-type double-float)
  816. )
  817. (def-c-call-out y1 (:arguments (x double-float))
  818.                    (:return-type double-float)
  819. )
  820. (def-c-call-out yn (:arguments (n int) (x double-float))
  821.                    (:return-type double-float)
  822. )
  823. (def-c-call-out expm1 (:arguments (x double-float))
  824.                       (:return-type double-float)
  825. )
  826. (def-c-call-out log1p (:arguments (x double-float))
  827.                       (:return-type double-float)
  828. )
  829. (def-c-call-out cbrt (:arguments (x double-float))
  830.                      (:return-type double-float)
  831. )
  832. (def-c-call-out rint (:arguments (x double-float))
  833.                      (:return-type double-float)
  834. )
  835. (def-c-call-out isinf (:arguments (x double-float))
  836.                       (:return-type boolean)
  837. )
  838. (def-c-call-out isnan (:arguments (x double-float))
  839.                       (:return-type boolean)
  840. )
  841. (def-c-call-out finite (:arguments (x double-float))
  842.                        (:return-type boolean)
  843. )
  844. (def-c-call-out infnan (:arguments (error int))
  845.                        (:return-type double-float)
  846. )
  847. (def-c-call-out copysign (:arguments (x double-float) (y double-float))
  848.                          (:return-type double-float)
  849. )
  850.  
  851. (defconstant HUGE DBL_MAX)
  852. (defconstant M_E         2.7182818284590452354d0)
  853. (defconstant M_LOG2E     1.4426950408889634074d0)
  854. (defconstant M_LOG10E    0.43429448190325182765d0)
  855. (defconstant M_LN2       0.69314718055994530942d0)
  856. (defconstant M_LN10      2.30258509299404568402d0)
  857. (defconstant M_PI        3.14159265358979323846d0)
  858. (defconstant M_PI_2      1.57079632679489661923d0)
  859. (defconstant M_1_PI      0.31830988618379067154d0)
  860. (defconstant M_PI_4      0.78539816339744830962d0)
  861. (defconstant M_2_PI      0.63661977236758134308d0)
  862. (defconstant M_2_SQRTPI  1.12837916709551257390d0)
  863. (defconstant M_SQRT2     1.41421356237309504880d0)
  864. (defconstant M_SQRT1_2   0.70710678118654752440d0)
  865. (defconstant PI M_PI)
  866. (defconstant PI2 M_PI_2)
  867.  
  868. ; ============================= <posix1_lim.h> ================================
  869.  
  870. ; ----------------------------- <posix1_lim.h> --------------------------------
  871.  
  872. (defconstant _POSIX_ARG_MAX 4096)
  873. (defconstant _POSIX_CHILD_MAX 6)
  874. (defconstant _POSIX_LINK_MAX 8)
  875. (defconstant _POSIX_MAX_CANON 255)
  876. (defconstant _POSIX_MAX_INPUT 255)
  877. (defconstant _POSIX_NGROUPS_MAX 0)
  878. (defconstant _POSIX_OPEN_MAX 16)
  879. (defconstant _POSIX_NAME_MAX 14)
  880. (defconstant _POSIX_PATH_MAX 255)
  881. (defconstant _POSIX_PIPE_BUF 512)
  882. (defconstant _POSIX_SSIZE_MAX 32767)
  883. (defconstant _POSIX_STREAM_MAX 8)
  884. (defconstant _POSIX_TZNAME_MAX 3)
  885.  
  886. ; ---------------------------- <linux/limits.h> -------------------------------
  887.  
  888. (eval-when (load compile eval)
  889. (defconstant NR_OPEN 256)
  890. (defconstant NGROUPS_MAX 32)
  891. (defconstant ARG_MAX 131072)
  892. (defconstant CHILD_MAX 999)
  893. (defconstant OPEN_MAX 256)
  894. (defconstant LINK_MAX 127)
  895. (defconstant MAX_CANON 255)
  896. (defconstant MAX_INPUT 255)
  897. (defconstant NAME_MAX 255)
  898. (defconstant PATH_MAX 1024)
  899. (defconstant PIPE_BUF 4096)
  900. )
  901.  
  902. ; ----------------------------- <posix1_lim.h> --------------------------------
  903.  
  904. (defconstant TZNAME_MAX 50)
  905. (defconstant SSIZE_MAX INT_MAX)
  906. (defconstant STREAM_MAX OPEN_MAX)
  907.  
  908. ; ============================= <posix2_lim.h> ================================
  909.  
  910. (defconstant _POSIX2_BC_BASE_MAX 99)
  911. (defconstant _POSIX2_BC_DIM_MAX 2048)
  912. (defconstant _POSIX2_BC_SCALE_MAX 99)
  913. (defconstant _POSIX2_BC_STRING_MAX 1000)
  914. (defconstant _POSIX2_EQUIV_CLASS_MAX 2)
  915. (defconstant _POSIX2_EXPR_NEST_MAX 32)
  916. (defconstant _POSIX2_LINE_MAX 2048)
  917. (defconstant _POSIX2_RE_DUP_MAX 255)
  918.  
  919. (defconstant BC_BASE_MAX _POSIX2_BC_BASE_MAX)
  920. (defconstant BC_DIM_MAX _POSIX2_BC_DIM_MAX)
  921. (defconstant BC_SCALE_MAX _POSIX2_BC_SCALE_MAX)
  922. (defconstant BC_STRING_MAX _POSIX2_BC_STRING_MAX)
  923. (defconstant EQUIV_CLASS_MAX _POSIX2_EQUIV_CLASS_MAX)
  924. (defconstant EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX)
  925. (defconstant LINE_MAX _POSIX2_LINE_MAX)
  926. (defconstant RE_DUP_MAX 32767)
  927.  
  928. ; ============================= <posix_opt.h> =================================
  929.  
  930. (defconstant _POSIX_CHOWN_RESTRICTED t)
  931. (defconstant _POSIX_NO_TRUNC t)
  932. (defconstant _POSIX_VDISABLE #\Null)
  933. (defconstant _POSIX_JOB_CONTROL t)
  934. (defconstant _POSIX_SAVED_IDS t)
  935.  
  936. ; ============================== <unistd.h> ===================================
  937.  
  938. (defconstant _POSIX_VERSION 199009)
  939. (defconstant _POSIX2_C_VERSION 199912)
  940. (defconstant _POSIX2_C_BIND t)
  941. (defconstant _POSIX2_C_DEV t)
  942. (defconstant _POSIX2_SW_DEV t)
  943.  
  944. (defconstant STDIN_FILENO 0)
  945. (defconstant STDOUT_FILENO 1)
  946. (defconstant STDERR_FILENO 2)
  947.  
  948. (defconstant R_OK 4)
  949. (defconstant W_OK 2)
  950. (defconstant X_OK 1)
  951. (defconstant F_OK 0)
  952.  
  953. (def-c-call-out access (:arguments (name c-string) (type int))
  954.                        (:return-type int)
  955. )
  956.  
  957. (defconstant SEEK_SET 0)
  958. (defconstant SEEK_CUR 1)
  959. (defconstant SEEK_END 2)
  960.  
  961. (def-c-call-out lseek (:arguments (fd int) (offset off_t) (whence int))
  962.                       (:return-type off_t)
  963. )
  964.  
  965. (def-c-call-out close (:arguments (fd int))
  966.                       (:return-type int)
  967. )
  968.  
  969. (def-c-call-out read (:arguments (fd int) (buf c-pointer) (nbytes size_t))
  970.                      (:return-type ssize_t)
  971.                      (:name "full_read")
  972. )
  973. (def-c-call-out write (:arguments (fd int) (buf c-pointer) (nbytes size_t))
  974.                       (:return-type ssize_t)
  975.                       (:name "full_write")
  976. )
  977.  
  978. (def-c-call-out pipe (:arguments (pipedes (c-ptr (c-array int 2)) :out))
  979.                      (:return-type int)
  980. )
  981.  
  982. (def-c-call-out alarm (:arguments (seconds uint))
  983.                       (:return-type uint)
  984. )
  985.  
  986. (def-c-call-out sleep (:arguments (seconds uint))
  987.                       (:return-type uint)
  988. )
  989.  
  990. (def-c-call-out pause (:arguments)
  991.                       (:return-type int)
  992. )
  993.  
  994. (def-c-call-out chown (:arguments (file c-string) (owner uid_t) (group gid_t))
  995.                       (:return-type int)
  996. )
  997. (def-c-call-out fchown (:arguments (fd int) (owner uid_t) (group gid_t))
  998.                        (:return-type int)
  999. )
  1000.  
  1001. (def-c-call-out chdir (:arguments (path c-string))
  1002.                       (:return-type int)
  1003. )
  1004.  
  1005. ;(def-c-call-out getcwd (:arguments (buf c-string :out) (size size_t)) ; ??
  1006. ;                       (:return-type c-string)
  1007. ;)
  1008.  
  1009. (def-c-call-out get_current_dir_name (:arguments)
  1010.                                      (:return-type c-string :malloc-free)
  1011. )
  1012.  
  1013. ;(def-c-call-out getwd (:arguments (buf c-string :out)) ; ??
  1014. ;                      (:return-type c-string)
  1015. ;)
  1016.  
  1017. (def-c-call-out dup (:arguments (fd int))
  1018.                     (:return-type int)
  1019. )
  1020.  
  1021. (def-c-call-out dup2 (:arguments (fd int) (fd2 int))
  1022.                      (:return-type int)
  1023. )
  1024.  
  1025. (def-c-var environ (:type (c-array-ptr c-string)) (:read-only t))
  1026.  
  1027. ;(def-c-call-out execve (:arguments (path c-string) (argv c-pointer) (envp c-pointer)) ; ??
  1028. ;                       (:return-type int)
  1029. ;)
  1030. ;(def-c-call-out execv (:arguments (path c-string) (argv c-pointer)) ; ??
  1031. ;                      (:return-type int)
  1032. ;)
  1033. (def-c-call-out execle0 (:arguments (path c-string) (argv0 c-string) (null c-string) (envp c-pointer))
  1034.                         (:return-type int)
  1035.                         (:name "execle")
  1036. )
  1037. (def-c-call-out execle1 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (null c-string) (envp c-pointer))
  1038.                         (:return-type int)
  1039.                         (:name "execle")
  1040. )
  1041. (def-c-call-out execle2 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (argv2 c-string) (null c-string) (envp c-pointer))
  1042.                         (:return-type int)
  1043.                         (:name "execle")
  1044. )
  1045. (def-c-call-out execle3 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (argv2 c-string) (argv3 c-string) (null c-string) (envp c-pointer))
  1046.                         (:return-type int)
  1047.                         (:name "execle")
  1048. )
  1049. (def-c-call-out execl0 (:arguments (path c-string) (argv0 c-string) (null c-string))
  1050.                        (:return-type int)
  1051.                        (:name "execl")
  1052. )
  1053. (def-c-call-out execl1 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (null c-string))
  1054.                        (:return-type int)
  1055.                        (:name "execl")
  1056. )
  1057. (def-c-call-out execl2 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (argv2 c-string) (null c-string))
  1058.                        (:return-type int)
  1059.                        (:name "execl")
  1060. )
  1061. (def-c-call-out execl3 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (argv2 c-string) (argv3 c-string) (null c-string))
  1062.                        (:return-type int)
  1063.                        (:name "execl")
  1064. )
  1065. ;(def-c-call-out execvp (:arguments (path c-string) (argv c-pointer)) ; ??
  1066. ;                       (:return-type int)
  1067. ;)
  1068. (def-c-call-out execlp0 (:arguments (path c-string) (argv0 c-string) (null c-string))
  1069.                         (:return-type int)
  1070.                         (:name "execlp")
  1071. )
  1072. (def-c-call-out execlp1 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (null c-string))
  1073.                         (:return-type int)
  1074.                         (:name "execlp")
  1075. )
  1076. (def-c-call-out execlp2 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (argv2 c-string) (null c-string))
  1077.                         (:return-type int)
  1078.                         (:name "execlp")
  1079. )
  1080. (def-c-call-out execlp3 (:arguments (path c-string) (argv0 c-string) (argv1 c-string) (argv2 c-string) (argv3 c-string) (null c-string))
  1081.                         (:return-type int)
  1082.                         (:name "execlp")
  1083. )
  1084.  
  1085. (def-c-call-out _exit (:arguments (status int))
  1086.                       (:return-type nil)
  1087. )
  1088.  
  1089. (defconstant _PC_LINK_MAX            0)
  1090. (defconstant _PC_MAX_CANON           1)
  1091. (defconstant _PC_MAX_INPUT           2)
  1092. (defconstant _PC_NAME_MAX            3)
  1093. (defconstant _PC_PATH_MAX            4)
  1094. (defconstant _PC_PIPE_BUF            5)
  1095. (defconstant _PC_CHOWN_RESTRICTED    6)
  1096. (defconstant _PC_NO_TRUNC            7)
  1097. (defconstant _PC_VDISABLE            8)
  1098. (def-c-call-out pathconf (:arguments (path c-string) (name int))
  1099.                          (:return-type long)
  1100. )
  1101. (def-c-call-out fpathconf (:arguments (fd int) (name int))
  1102.                           (:return-type long)
  1103. )
  1104.  
  1105. (def-c-enum sysconf-name
  1106.   _SC_ARG_MAX
  1107.   _SC_CHILD_MAX
  1108.   _SC_CLK_TCK
  1109.   _SC_NGROUPS_MAX
  1110.   _SC_OPEN_MAX
  1111.   _SC_STREAM_MAX
  1112.   _SC_TZNAME_MAX
  1113.   _SC_JOB_CONTROL
  1114.   _SC_SAVED_IDS
  1115.   _SC_VERSION
  1116.   _SC_CLOCKS_PER_SEC
  1117.   _SC_BC_BASE_MAX
  1118.   _SC_BC_DIM_MAX
  1119.   _SC_BC_SCALE_MAX
  1120.   _SC_BC_STRING_MAX
  1121.   _SC_COLL_WEIGHTS_MAX
  1122.   _SC_EQUIV_CLASS_MAX
  1123.   _SC_EXPR_NEST_MAX
  1124.   _SC_LINE_MAX
  1125.   _SC_RE_DUP_MAX
  1126.   _SC_2_VERSION
  1127.   _SC_2_C_BIND
  1128.   _SC_2_C_DEV
  1129.   _SC_2_FORT_DEV
  1130.   _SC_2_FORT_RUN
  1131.   _SC_2_SW_DEV
  1132.   _SC_2_LOCALEDEF
  1133. )
  1134. (def-c-call-out sysconf (:arguments (name int))
  1135.                         (:return-type long)
  1136. )
  1137.  
  1138. (defconstant _CS_PATH 0)
  1139. ;(def-c-call-out confstr (:arguments (name int) (buf c-pointer) (len size_t)) ; ??
  1140. ;                        (:return-type size_t)
  1141. ;)
  1142.  
  1143. (def-c-call-out getpid (:arguments)
  1144.                        (:return-type pid_t)
  1145. )
  1146.  
  1147. (def-c-call-out getppid (:arguments)
  1148.                         (:return-type pid_t)
  1149. )
  1150.  
  1151. ;(def-c-call-out getpgid (:arguments (pid pid_t))
  1152. ;                        (:return-type pid_t)
  1153. ;) ; non-existent
  1154.  
  1155. (def-c-call-out getpgrp (:arguments)
  1156.                         (:return-type pid_t)
  1157. )
  1158.  
  1159. (def-c-call-out setpgid (:arguments (pid pid_t) (pgid pid_t))
  1160.                         (:return-type int)
  1161. )
  1162.  
  1163. (def-c-call-out setpgrp (:arguments)
  1164.                         (:return-type int)
  1165. )
  1166.  
  1167. (def-c-call-out setsid (:arguments)
  1168.                        (:return-type pid_t)
  1169. )
  1170.  
  1171. (def-c-call-out getuid (:arguments)
  1172.                        (:return-type uid_t)
  1173. )
  1174.  
  1175. (def-c-call-out geteuid (:arguments)
  1176.                         (:return-type uid_t)
  1177. )
  1178.  
  1179. (def-c-call-out getgid (:arguments)
  1180.                        (:return-type gid_t)
  1181. )
  1182.  
  1183. (def-c-call-out getegid (:arguments)
  1184.                         (:return-type gid_t)
  1185. )
  1186.  
  1187. ;(def-c-call-out getgroups (:arguments (size int) (list (c-ptr (c-array gid_t ??)) :out)) ; ??
  1188. ;                          (:return-type int)
  1189. ;)
  1190.  
  1191. (def-c-call-out setuid (:arguments (uid uid_t))
  1192.                        (:return-type int)
  1193. )
  1194.  
  1195. (def-c-call-out setreuid (:arguments (ruid uid_t) (euid uid_t))
  1196.                          (:return-type int)
  1197. )
  1198.  
  1199. (def-c-call-out seteuid (:arguments (uid uid_t))
  1200.                         (:return-type int)
  1201. )
  1202.  
  1203. (def-c-call-out setgid (:arguments (gid gid_t))
  1204.                        (:return-type int)
  1205. )
  1206.  
  1207. (def-c-call-out setregid (:arguments (rgid gid_t) (egid gid_t))
  1208.                          (:return-type int)
  1209. )
  1210.  
  1211. (def-c-call-out setegid (:arguments (gid gid_t))
  1212.                         (:return-type int)
  1213. )
  1214.  
  1215. (def-c-call-out cuserid (:arguments (null c-string)) ; ??
  1216.                         (:return-type c-string)
  1217. )
  1218.  
  1219. (def-c-call-out ctermid (:arguments (null c-string)) ; ??
  1220.                         (:return-type c-string)
  1221. )
  1222.  
  1223. (def-c-call-out ttyname (:arguments (fd int))
  1224.                         (:return-type c-string)
  1225. )
  1226.  
  1227. (def-c-call-out isatty (:arguments (fd int))
  1228.                        (:return-type boolean)
  1229. )
  1230.  
  1231. (def-c-call-out link (:arguments (from c-string) (to c-string))
  1232.                      (:return-type int)
  1233. )
  1234.  
  1235. (def-c-call-out symlink (:arguments (from c-string) (to c-string))
  1236.                         (:return-type int)
  1237. )
  1238.  
  1239. ;(def-c-call-out readlink (:arguments (path c-string) (buf c-pointer) (len size_t)) ; ??
  1240. ;                         (:return-type int)
  1241. ;)
  1242.  
  1243. (def-c-call-out unlink (:arguments (path c-string))
  1244.                        (:return-type int)
  1245. )
  1246.  
  1247. (def-c-call-out rmdir (:arguments (path c-string))
  1248.                       (:return-type int)
  1249. )
  1250.  
  1251. (def-c-call-out tcgetpgrp (:arguments (fd int))
  1252.                           (:return-type pid_t)
  1253. )
  1254.  
  1255. (def-c-call-out tcsetpgrp (:arguments (fd int) (pgrp_id pid_t))
  1256.                           (:return-type int)
  1257. )
  1258.  
  1259. (def-c-call-out getlogin (:arguments)
  1260.                          (:return-type c-string)
  1261. )
  1262.  
  1263. ;(def-c-call-out setlogin (:arguments (name c-string))
  1264. ;                         (:return-type int)
  1265. ;) ; non-existent
  1266.  
  1267. (def-c-call-out getopt (:arguments (argc int) (argv c-pointer) (opts c-string)) ; ??
  1268.                        (:return-type int)
  1269. )
  1270. (def-c-var opterr (:type int))
  1271. (def-c-var optind (:type int))
  1272. (def-c-var optopt (:type int))
  1273. (def-c-var optarg (:type c-string))
  1274.  
  1275. ;(def-c-call-out gethostname (:arguments (name c-pointer) (len size_t)) ; ??
  1276. ;                            (:return-type
  1277. ;)
  1278.  
  1279. ;(def-c-call-out sethostname (:arguments (name (c-pointer) (len sizet)) ; ??
  1280. ;                            (:return-type int)
  1281. ;)
  1282.  
  1283. (def-c-call-out gethostid (:arguments)
  1284.                           (:return-type long)
  1285. )
  1286.  
  1287. (def-c-call-out sethostid (:arguments (id long))
  1288.                           (:return-type int)
  1289. )
  1290.  
  1291. (def-c-call-out getpagesize (:arguments)
  1292.                             (:return-type size_t)
  1293. )
  1294.  
  1295. (def-c-call-out getdtablesize (:arguments)
  1296.                               (:return-type int)
  1297. )
  1298.  
  1299. (def-c-call-out fsync (:arguments (fd int))
  1300.                       (:return-type int)
  1301. )
  1302.  
  1303. (def-c-call-out sync (:arguments)
  1304.                      (:return-type int)
  1305. )
  1306.  
  1307. (def-c-call-out vhangup (:arguments)
  1308.                         (:return-type int)
  1309. )
  1310.  
  1311. (def-c-call-out acct (:arguments (name c-string))
  1312.                      (:return-type int)
  1313. )
  1314.  
  1315. (def-c-call-out chroot (:arguments (path c-string))
  1316.                        (:return-type int)
  1317. )
  1318.  
  1319. (def-c-call-out swapon (:arguments (path c-string))
  1320.                        (:return-type int)
  1321. )
  1322.  
  1323. (def-c-call-out getusershell (:arguments)
  1324.                              (:return-type c-string)
  1325. )
  1326. (def-c-call-out setusershell (:arguments)
  1327.                              (:return-type nil)
  1328. )
  1329. (def-c-call-out endusershell (:arguments)
  1330.                              (:return-type nil)
  1331. )
  1332.  
  1333. (def-c-call-out getpass (:arguments (prompt c-string))
  1334.                         (:return-type c-string)
  1335. )
  1336.  
  1337. (def-c-call-out brk (:arguments (end_data_segment c-pointer))
  1338.                     (:return-type int)
  1339. )
  1340. (def-c-call-out sbrk (:arguments (increment ptrdiff_t))
  1341.                      (:return-type int)
  1342. )
  1343.  
  1344. (def-c-call-out crypt (:arguments (key c-string) (salt c-string))
  1345.                       (:return-type c-string)
  1346. )
  1347. (def-c-call-out encrypt (:arguments (block (c-ptr (c-array character 64))) (edflag boolean))
  1348.                         (:return-type nil)
  1349. )
  1350. (def-c-call-out setkey (:arguments (key c-string))
  1351.                        (:return-type nil)
  1352. )
  1353.  
  1354. (def-c-call-out ftruncate (:arguments (fildes int) (length size_t))
  1355.                           (:return-type int)
  1356. )
  1357. (def-c-call-out truncate (:arguments (path c-string) (length size_t))
  1358.                          (:return-type int)
  1359. )
  1360.  
  1361. (def-c-call-out ioperm (:arguments (from ulong) (num ulong) (turn_on boolean))
  1362.                        (:return-type int)
  1363. )
  1364. (def-c-call-out iopl (:arguments (level int))
  1365.                      (:return-type int)
  1366. )
  1367.  
  1368. (def-c-call-out mktemp (:arguments (template c-string :in :alloca)) ; actually :in-out
  1369.                        (:return-type c-string)
  1370. )
  1371. ;(def-c-call-out mkstemp (:arguments (template c-string :in-out)); ??
  1372. ;                        (:return-type int)
  1373. ;)
  1374.  
  1375. (def-c-call-out nice (:arguments (val int))
  1376.                      (:return-type int)
  1377. )
  1378.  
  1379. ;(def-c-call-out profil (:arguments (buf c-pointer) (bufsiz int) (offset int) (scale int)) ; ??
  1380. ;                       (:return-type int)
  1381. ;)
  1382.  
  1383. (def-c-call-out usleep (:arguments (usec ulong))
  1384.                        (:return-type nil)
  1385. )
  1386.  
  1387. #| ;; Present in libc-4, but not libc-5.
  1388. (def-c-call-out ustat (:arguments (dev dev_t) (ubuf (c-ptr ustat) :out))
  1389.                       (:return-type int)
  1390. )
  1391. |#
  1392.  
  1393. (def-c-call-out idle (:arguments)
  1394.                      (:return-type int)
  1395. )
  1396. (def-c-call-out reboot (:arguments (magic int) (magic_too int) (flag int))
  1397.                        (:return-type int)
  1398. )
  1399.  
  1400. (def-c-call-out swapoff (:arguments (specialfile c-string))
  1401.                         (:return-type int)
  1402. )
  1403.  
  1404. (def-c-call-out uselib (:arguments (filename c-string))
  1405.                        (:return-type int)
  1406. )
  1407.  
  1408. ;(def-c-call-out getdomainname (:arguments (name c-pointer) (len size_t)) ; ??
  1409. ;                              (:return-type int)
  1410. ;)
  1411. ;(def-c-call-out setdomainname (:arguments (name c-pointer) (len size_t)) ; ??
  1412. ;                              (:return-type int)
  1413. ;)
  1414.  
  1415. ;(def-c-call-out realpath (:arguments (path c-pointer) (resolved_path c-pointer :out)) ; ??
  1416. ;                         (:return-type int)
  1417. ;)
  1418.  
  1419. ; ============================== <fcntl.h> ====================================
  1420.  
  1421. ; ---------------------------- <linux/fcntl.h> --------------------------------
  1422.  
  1423. (defconstant O_ACCMODE    #o003)
  1424. (defconstant O_RDONLY       #o0)
  1425. (defconstant O_WRONLY       #o1)
  1426. (defconstant O_RDWR         #o2)
  1427. (defconstant O_CREAT      #o100)
  1428. (defconstant O_EXCL       #o200)
  1429. (defconstant O_NOCTTY     #o400)
  1430. (defconstant O_TRUNC     #o1000)
  1431. (defconstant O_APPEND    #o2000)
  1432. (defconstant O_NONBLOCK  #o4000)
  1433. (defconstant O_NDELAY    O_NONBLOCK)
  1434. (defconstant O_SYNC     #o10000)
  1435. (defconstant FASYNC     #o20000)
  1436. (defconstant F_DUPFD    0)
  1437. (defconstant F_GETFD    1)
  1438. (defconstant F_SETFD    2)
  1439. (defconstant F_GETFL    3)
  1440. (defconstant F_SETFL    4)
  1441. (defconstant F_GETLK    5)
  1442. (defconstant F_SETLK    6)
  1443. (defconstant F_SETLKW   7)
  1444. (defconstant F_SETOWN   8)
  1445. (defconstant F_GETOWN   9)
  1446.  
  1447. (defconstant FD_CLOEXEC 1)
  1448.  
  1449. (defconstant F_RDLCK    0)
  1450. (defconstant F_WRLCK    1)
  1451. (defconstant F_UNLCK    2)
  1452.  
  1453. (defconstant F_EXLCK    4)
  1454. (defconstant F_SHLCK    8)
  1455.  
  1456. (def-c-struct flock
  1457.   (l_type short)
  1458.   (l_whence short)
  1459.   (l_start off_t)
  1460.   (l_len off_t)
  1461.   (l_pid pid_t)
  1462. )
  1463.  
  1464. ; ------------------------------ <fcntl.h> ------------------------------------
  1465.  
  1466. (defconstant FNDELAY O_NDELAY)
  1467.  
  1468. (def-c-call-out creat (:arguments (filename c-string) (mode mode_t))
  1469.                       (:return-type int)
  1470. )
  1471.  
  1472. (def-c-call-out fcntl (:arguments (fildes int) (cmd int) (arg c-pointer)) ; ??
  1473.                       (:return-type int)
  1474. )
  1475.  
  1476. (def-c-call-out open (:arguments (filename c-string) (flags int) (mode mode_t))
  1477.                      (:return-type int)
  1478. )
  1479.  
  1480. ; ============================= <sys/stat.h> ==================================
  1481.  
  1482. (c-lines "#include <sys/stat.h>~%")
  1483.  
  1484. ; ---------------------------- <linux/stat.h> ---------------------------------
  1485.  
  1486. (defconstant S_IFMT  #o0170000)
  1487. (defconstant S_IFSOCK #o140000)
  1488. (defconstant S_IFLNK  #o120000)
  1489. (defconstant S_IFREG  #o100000)
  1490. (defconstant S_IFBLK  #o060000)
  1491. (defconstant S_IFDIR  #o040000)
  1492. (defconstant S_IFCHR  #o020000)
  1493. (defconstant S_IFIFO  #o010000)
  1494. (defconstant S_ISUID  #o004000)
  1495. (defconstant S_ISGID  #o002000)
  1496. (defconstant S_ISVTX  #o001000)
  1497.  
  1498. (defmacro S_ISLNK (m) `(= (logand ,m S_IFMT) S_IFLNK))
  1499. (defmacro S_ISREG (m) `(= (logand ,m S_IFMT) S_IFREG))
  1500. (defmacro S_ISDIR (m) `(= (logand ,m S_IFMT) S_IFDIR))
  1501. (defmacro S_ISCHR (m) `(= (logand ,m S_IFMT) S_IFCHR))
  1502. (defmacro S_ISBLK (m) `(= (logand ,m S_IFMT) S_IFBLK))
  1503. (defmacro S_ISFIFO (m) `(= (logand ,m S_IFMT) S_IFFIFO))
  1504. (defmacro S_ISSOCK (m) `(= (logand ,m S_IFMT) S_IFSOCK))
  1505.  
  1506. (defconstant S_IRWXU #o0700)
  1507. (defconstant S_IRUSR #o0400)
  1508. (defconstant S_IWUSR #o0200)
  1509. (defconstant S_IXUSR #o0100)
  1510.  
  1511. (defconstant S_IRWXG #o0070)
  1512. (defconstant S_IRGRP #o0040)
  1513. (defconstant S_IWGRP #o0020)
  1514. (defconstant S_IXGRP #o0010)
  1515.  
  1516. (defconstant S_IRWXO #o0007)
  1517. (defconstant S_IROTH #o0004)
  1518. (defconstant S_IWOTH #o0002)
  1519. (defconstant S_IXOTH #o0001)
  1520.  
  1521. ; ----------------------------- <sys/stat.h> ----------------------------------
  1522.  
  1523. (def-c-struct stat
  1524.   (st_dev dev_t)
  1525.   (__pad1 ushort)
  1526.   (st_ino ino_t)
  1527.   (st_mode umode_t)
  1528.   (st_nlink nlink_t)
  1529.   (st_uid uid_t)
  1530.   (st_gid gid_t)
  1531.   (st_rdev dev_t)
  1532.   (__pad2 ushort)
  1533.   (st_size off_t)
  1534.   (st_blksize ulong)
  1535.   (st_blocks ulong)
  1536.   (st_atime time_t)
  1537.   (__unused1 ulong)
  1538.   (st_mtime time_t)
  1539.   (__unused2 ulong)
  1540.   (st_ctime time_t)
  1541.   (__unused3 ulong)
  1542.   (__unused4 ulong)
  1543.   (__unused5 ulong)
  1544. )
  1545.  
  1546. (defconstant S_IREAD S_IRUSR)
  1547. (defconstant S_IWRITE S_IWUSR)
  1548. (defconstant S_IEXEC S_IXUSR)
  1549.  
  1550. (def-c-call-out chmod (:arguments (path c-string) (mode mode_t))
  1551.                       (:return-type int)
  1552. )
  1553.  
  1554. (def-c-call-out fchmod (:arguments (fildes int) (mode mode_t))
  1555.                        (:return-type int)
  1556. )
  1557.  
  1558. (def-c-call-out fstat (:arguments (fildes int) (stat_buf (c-ptr stat) :out))
  1559.                       (:return-type int)
  1560. )
  1561.  
  1562. (def-c-call-out mkdir (:arguments (path c-string) (mode mode_t))
  1563.                       (:return-type int)
  1564. )
  1565.  
  1566. (def-c-call-out mknod (:arguments (path c-string) (mode mode_t) (dev dev_t))
  1567.                       (:return-type int)
  1568. )
  1569.  
  1570. (def-c-call-out mkfifo (:arguments (path c-string) (mode mode_t))
  1571.                        (:return-type int)
  1572. )
  1573.  
  1574. (def-c-call-out stat (:arguments (filename c-string) (stat_buf (c-ptr stat) :out))
  1575.                      (:return-type int)
  1576. )
  1577.  
  1578. (def-c-call-out lstat (:arguments (filename c-string) (stat_buf (c-ptr stat) :out))
  1579.                       (:return-type int)
  1580. )
  1581.  
  1582. (def-c-call-out umask (:arguments (mask mode_t))
  1583.                       (:return-type mode_t)
  1584. )
  1585.  
  1586. ; ============================== <stdio.h> ====================================
  1587.  
  1588. (defconstant EOF -1)
  1589.  
  1590. (defconstant _IOFBF 0)
  1591. (defconstant _IOLBF 1)
  1592. (defconstant _IONBF 2)
  1593.  
  1594. (defconstant SEEK_SET 0)
  1595. (defconstant SEEK_CUR 1)
  1596. (defconstant SEEK_END 2)
  1597.  
  1598. (def-c-type FILE
  1599.   (c-struct vector
  1600.     ; components unknown
  1601. ) )
  1602. (def-c-type fpos_t _G_fpos_t)
  1603.  
  1604. (defconstant FOPEN_MAX _G_FOPEN_MAX)
  1605. (defconstant FILENAME_MAX _G_FILENAME_MAX)
  1606.  
  1607. (defconstant TMP_MAX 238328)
  1608.  
  1609. (defconstant L_ctermid     9)
  1610. (defconstant L_cuserid     9)
  1611. (defconstant P_tmpdir      "/tmp")
  1612. (defconstant L_tmpnam      20)
  1613.  
  1614. (def-c-call-out clearerr (:arguments (fp c-pointer))
  1615.                          (:return-type nil)
  1616. )
  1617. (def-c-call-out fclose (:arguments (fp c-pointer))
  1618.                        (:return-type int)
  1619. )
  1620. (def-c-call-out feof (:arguments (fp c-pointer))
  1621.                      (:return-type int)
  1622. )
  1623. (def-c-call-out ferror (:arguments (fp c-pointer))
  1624.                        (:return-type int)
  1625. )
  1626. (def-c-call-out fflush (:arguments (fp c-pointer))
  1627.                        (:return-type int)
  1628. )
  1629. (def-c-call-out fgetc (:arguments (fp c-pointer))
  1630.                       (:return-type int)
  1631. )
  1632. (def-c-call-out fgetpos (:arguments (fp c-pointer) (pos (c-ptr fpos_t) :out))
  1633.                         (:return-type int)
  1634. )
  1635. ;(def-c-call-out fgets (:arguments (buf c-pointer) (size int) (fp c-pointer)) ; ??
  1636. ;                      (:return-type c-string)
  1637. ;)
  1638. (def-c-call-out fopen (:arguments (path c-string) (mode c-string))
  1639.                       (:return-type c-pointer)
  1640. )
  1641. (def-c-call-out fprintf0 (:arguments (fp c-pointer) (format c-string))
  1642.                          (:return-type int)
  1643.                          (:name "fprintf")
  1644. )
  1645. (def-c-call-out fprintf1i (:arguments (fp c-pointer) (format c-string) (arg int))
  1646.                           (:return-type int)
  1647.                           (:name "fprintf")
  1648. )
  1649. (def-c-call-out fprintf1l (:arguments (fp c-pointer) (format c-string) (arg long))
  1650.                           (:return-type int)
  1651.                           (:name "fprintf")
  1652. )
  1653. (def-c-call-out fprintf1d (:arguments (fp c-pointer) (format c-string) (arg double-float))
  1654.                           (:return-type int)
  1655.                           (:name "fprintf")
  1656. )
  1657. (def-c-call-out fputc (:arguments (c int) (fp c-pointer))
  1658.                       (:return-type int)
  1659. )
  1660. (def-c-call-out fputs (:arguments (str c-string) (fp c-pointer))
  1661.                       (:return-type int)
  1662. )
  1663. ;(def-c-call-out fread (:arguments (ptr c-pointer) (size size_t) (nmemb size_t) (fp c-pointer)) ; ??
  1664. ;                      (:return-type size_t)
  1665. ;)
  1666. ;(def-c-call-out freopen (:arguments (path c-string) (mode c-string) (fp c-pointer :in-out)) ; ??
  1667. ;                        (:return-type c-pointer)
  1668. ;)
  1669. (def-c-call-out fscanf0 (:arguments (fp c-pointer) (format c-string))
  1670.                         (:return-type int)
  1671.                         (:name "fscanf")
  1672. )
  1673. (def-c-call-out fscanf1i (:arguments (fp c-pointer) (format c-string) (arg (c-ptr int) :out))
  1674.                          (:return-type int)
  1675.                          (:name "fscanf")
  1676. )
  1677. (def-c-call-out fscanf1l (:arguments (fp c-pointer) (format c-string) (arg (c-ptr long) :out))
  1678.                          (:return-type int)
  1679.                          (:name "fscanf")
  1680. )
  1681. (def-c-call-out fscanf1d (:arguments (fp c-pointer) (format c-string) (arg (c-ptr double-float) :out))
  1682.                          (:return-type int)
  1683.                          (:name "fscanf")
  1684. )
  1685. (def-c-call-out fseek (:arguments (fp c-pointer) (offset long) (whence int))
  1686.                       (:return-type int)
  1687. )
  1688. (def-c-call-out fsetpos (:arguments (fp c-pointer) (pos (c-ptr fpos_t)))
  1689.                         (:return-type int)
  1690. )
  1691. (def-c-call-out ftell (:arguments (fp c-pointer))
  1692.                       (:return-type long)
  1693. )
  1694. ;(def-c-call-out fwrite (:arguments (ptr c-pointer) (size size_t) (nmemb size_t) (fp c-pointer)) ; ??
  1695. ;                       (:return-type size_t)
  1696. ;)
  1697. (def-c-call-out getc (:arguments (fp c-pointer))
  1698.                      (:return-type int)
  1699. )
  1700. (def-c-call-out getchar (:arguments)
  1701.                         (:return-type int)
  1702. )
  1703. ;(def-c-call-out gets (:arguments (buf c-pointer)) ; ??
  1704. ;                     (:return-type c-string)
  1705. ;)
  1706. (def-c-call-out perror (:arguments (s c-string))
  1707.                        (:return-type nil)
  1708. )
  1709. (def-c-call-out printf0 (:arguments (format c-string))
  1710.                         (:return-type int)
  1711.                         (:name "printf")
  1712. )
  1713. (def-c-call-out printf1i (:arguments (format c-string) (arg int))
  1714.                          (:return-type int)
  1715.                          (:name "printf")
  1716. )
  1717. (def-c-call-out printf1l (:arguments (format c-string) (arg long))
  1718.                          (:return-type int)
  1719.                          (:name "printf")
  1720. )
  1721. (def-c-call-out printf1d (:arguments (format c-string) (arg double-float))
  1722.                          (:return-type int)
  1723.                          (:name "printf")
  1724. )
  1725. (def-c-call-out putc (:arguments (c int) (fp c-pointer))
  1726.                      (:return-type int)
  1727. )
  1728. (def-c-call-out putchar (:arguments (c int))
  1729.                         (:return-type int)
  1730. )
  1731. (def-c-call-out puts (:arguments (str c-string))
  1732.                      (:return-type int)
  1733. )
  1734. (def-c-call-out remove (:arguments (path c-string))
  1735.                        (:return-type int)
  1736. )
  1737. (def-c-call-out rename (:arguments (old c-string) (new c-string))
  1738.                        (:return-type int)
  1739. )
  1740. (def-c-call-out rewind (:arguments (fp c-pointer))
  1741.                        (:return-type nil)
  1742. )
  1743. (def-c-call-out scanf0 (:arguments (format c-string))
  1744.                        (:return-type int)
  1745.                        (:name "scanf")
  1746. )
  1747. (def-c-call-out scanf1i (:arguments (format c-string) (arg (c-ptr int) :out))
  1748.                         (:return-type int)
  1749.                         (:name "scanf")
  1750. )
  1751. (def-c-call-out scanf1l (:arguments (format c-string) (arg (c-ptr long) :out))
  1752.                         (:return-type int)
  1753.                         (:name "scanf")
  1754. )
  1755. (def-c-call-out scanf1d (:arguments (format c-string) (arg (c-ptr double-float) :out))
  1756.                         (:return-type int)
  1757.                         (:name "scanf")
  1758. )
  1759. (def-c-call-out setbuf (:arguments (fp c-pointer) (buf c-pointer))
  1760.                        (:return-type nil)
  1761. )
  1762. (def-c-call-out setlinebuf (:arguments (fp c-pointer))
  1763.                            (:return-type nil)
  1764. )
  1765. (def-c-call-out setbuffer (:arguments (fp c-pointer) (buf c-pointer) (size int))
  1766.                           (:return-type nil)
  1767. )
  1768. (def-c-call-out setvbuf (:arguments (fp c-pointer) (buf c-pointer) (mode int) (size size_t))
  1769.                         (:return-type int)
  1770. )
  1771. ;(def-c-call-out sprintf0 (:arguments (str c-pointer :out) (format c-string)) ; ??
  1772. ;                         (:return-type int)
  1773. ;                         (:name "sprintf")
  1774. ;)
  1775. (def-c-call-out sscanf0 (:arguments (str c-string) (format c-string))
  1776.                         (:return-type int)
  1777.                         (:name "sscanf")
  1778. )
  1779. (def-c-call-out sscanf1i (:arguments (str c-string) (format c-string) (arg (c-ptr int) :out))
  1780.                          (:return-type int)
  1781.                          (:name "sscanf")
  1782. )
  1783. (def-c-call-out sscanf1l (:arguments (str c-string) (format c-string) (arg (c-ptr long) :out))
  1784.                          (:return-type int)
  1785.                          (:name "sscanf")
  1786. )
  1787. (def-c-call-out sscanf1d (:arguments (str c-string) (format c-string) (arg (c-ptr double-float) :out))
  1788.                          (:return-type int)
  1789.                          (:name "sscanf")
  1790. )
  1791. (def-c-call-out tmpfile (:arguments)
  1792.                         (:return-type c-pointer)
  1793. )
  1794. (def-c-call-out tmpnam (:arguments (s c-string :in :alloca)) ; :in-out ??
  1795.                        (:return-type c-string)
  1796. )
  1797. (def-c-call-out ungetc (:arguments (c int) (fp c-pointer))
  1798.                        (:return-type int)
  1799. )
  1800. (def-c-call-out fdopen (:arguments (fildes int) (mode c-string))
  1801.                        (:return-type c-pointer)
  1802. )
  1803. (def-c-call-out fileno (:arguments (fp c-pointer))
  1804.                        (:return-type int)
  1805. )
  1806. (def-c-call-out popen (:arguments (command c-string) (mode c-string))
  1807.                       (:return-type c-pointer)
  1808. )
  1809. (def-c-call-out pclose (:arguments (fp c-pointer))
  1810.                        (:return-type int)
  1811. )
  1812. (def-c-call-out getw (:arguments (fp c-pointer))
  1813.                      (:return-type int)
  1814. )
  1815. (def-c-call-out putw (:arguments (w int) (fp c-pointer))
  1816.                      (:return-type int)
  1817. )
  1818. (def-c-call-out tempnam (:arguments (dir c-string) (prefix c-string))
  1819.                         (:return-type c-string :malloc-free)
  1820. )
  1821.  
  1822. ; ============================== <dirent.h> ===================================
  1823.  
  1824. ; --------------------------- <linux/dirent.h> --------------------------------
  1825.  
  1826. (def-c-struct dirent
  1827.   (d_ino long)
  1828.   (d_off off_t)
  1829.   (d_reclen ushort)
  1830.   (d_name (c-array-max character #.(+ NAME_MAX 1)))
  1831. )
  1832.  
  1833. ; ------------------------------ <dirent.h> -----------------------------------
  1834.  
  1835. (def-c-struct DIR
  1836.   (dd_fd int)
  1837.   (dd_loc int)
  1838.   (dd_size int)
  1839.   (dd_buf (c-ptr dirent))
  1840. )
  1841.  
  1842. (def-c-call-out opendir (:arguments (name c-string))
  1843.                         (:return-type c-pointer)
  1844. )
  1845.  
  1846. (def-c-call-out closedir (:arguments (dirp c-pointer))
  1847.                          (:return-type int)
  1848. )
  1849.  
  1850. (def-c-call-out readdir (:arguments (dirp c-pointer))
  1851.                         (:return-type (c-ptr dirent))
  1852. )
  1853.  
  1854. (def-c-call-out rewinddir (:arguments (dirp c-pointer))
  1855.                           (:return-type nil)
  1856. )
  1857.  
  1858. (def-c-call-out seekdir (:arguments (dirp c-pointer) (pos off_t))
  1859.                         (:return-type nil)
  1860. )
  1861.  
  1862. (def-c-call-out telldir (:arguments (dirp c-pointer))
  1863.                         (:return-type off_t)
  1864. )
  1865.  
  1866. (def-c-call-out scandir (:arguments (dir c-string)
  1867.                                     (namelist (c-ptr (c-ptr (c-ptr dirent))) :out)
  1868.                                     (select (c-function (:arguments (d c-string))
  1869.                                                         (:return-type boolean)
  1870.                                     )       )
  1871.                                     (compar (c-function (:arguments (d1 (c-ptr (c-ptr dirent))) (d2 (c-ptr (c-ptr dirent))))
  1872.                                                         (:return-type int)
  1873.                                     )       )
  1874.                         )
  1875.                         (:return-type int)
  1876. )
  1877.  
  1878. (def-c-call-out alphasort (:arguments (d1 (c-ptr (c-ptr dirent))) (d2 (c-ptr (c-ptr dirent))))
  1879.                           (:return-type int)
  1880. )
  1881.  
  1882. ;(def-c-call-out getdirentries (:arguments (fd int) (buf c-pointer) (nbytes size_t) (basep (c-ptr off_t) :in-out))
  1883. ;                              (:return-type ssize_t)
  1884. ;)
  1885.  
  1886. ; ================================ <pwd.h> ====================================
  1887.  
  1888. (def-c-struct passwd
  1889.   (pw_name c-string)
  1890.   (pw_passwd c-string)
  1891.   (pw_uid uid_t)
  1892.   (pw_gid gid_t)
  1893.   (pw_gecos c-string)
  1894.   (pw_dir c-string)
  1895.   (pw_shell c-string)
  1896. )
  1897.  
  1898. (def-c-call-out __pwdopen (:arguments)
  1899.                           (:return-type c-pointer)
  1900. )
  1901.  
  1902. ;(def-c-call-out __pwdread (:arguments (stream c-pointer) (p c-pointer))
  1903. ;                          (:return-type (c-ptr passwd))
  1904. ;)
  1905.  
  1906. (def-c-call-out __pwdalloc (:arguments)
  1907.                            (:return-type c-pointer)
  1908. )
  1909.  
  1910. (def-c-call-out setpwent (:arguments)
  1911.                          (:return-type nil)
  1912. )
  1913.  
  1914. (def-c-call-out endpwent (:arguments)
  1915.                          (:return-type nil)
  1916. )
  1917.  
  1918. (def-c-call-out getpwent (:arguments)
  1919.                          (:return-type (c-ptr passwd))
  1920. )
  1921.  
  1922. ;(def-c-call-out getpw (:arguments (uid uid_t) (buf c-pointer))
  1923. ;                      (:return-type int)
  1924. ;)
  1925.  
  1926. (def-c-call-out fgetpwent (:arguments (stream c-pointer))
  1927.                           (:return-type (c-ptr passwd))
  1928. )
  1929.  
  1930. (def-c-call-out putpwent (:arguments (c-ptr passwd) (stream c-pointer))
  1931.                          (:return-type int)
  1932. )
  1933.  
  1934. (def-c-call-out getpwuid (:arguments (uid uid_t))
  1935.                          (:return-type (c-ptr passwd))
  1936. )
  1937.  
  1938. (def-c-call-out getpwnam (:arguments (name c-string))
  1939.                          (:return-type (c-ptr passwd))
  1940. )
  1941.  
  1942. ; ================================ <grp.h> ====================================
  1943.  
  1944. (def-c-struct group
  1945.   (gr_name c-string)
  1946.   (gr_passwd c-string)
  1947.   (gr_gid gid_t)
  1948.   (gr_mem (c-ptr c-string)) ; ??
  1949. )
  1950.  
  1951. (def-c-call-out __grpopen (:arguments)
  1952.                           (:return-type c-pointer)
  1953. )
  1954.  
  1955. ;(def-c-call-out __grpread (:arguments (stream c-pointer) (p c-pointer))
  1956. ;                          (:return-type (c-ptr group))
  1957. ;)
  1958.  
  1959. (def-c-call-out __grpalloc (:arguments)
  1960.                            (:return-type c-pointer)
  1961. )
  1962.  
  1963. (def-c-call-out setgrent (:arguments)
  1964.                          (:return-type nil)
  1965. )
  1966.  
  1967. (def-c-call-out endgrent (:arguments)
  1968.                          (:return-type nil)
  1969. )
  1970.  
  1971. (def-c-call-out getgrent (:arguments)
  1972.                          (:return-type (c-ptr group))
  1973. )
  1974.  
  1975. (def-c-call-out fgetgrent (:arguments (stream c-pointer))
  1976.                           (:return-type (c-ptr group))
  1977. )
  1978.  
  1979. (def-c-call-out getgrgid (:arguments (gid gid_t))
  1980.                          (:return-type (c-ptr group))
  1981. )
  1982.  
  1983. (def-c-call-out getgrnam (:arguments (name c-string))
  1984.                          (:return-type (c-ptr group))
  1985. )
  1986.  
  1987. ;(def-c-call-out setgroups (:arguments (n size_t) (groups (c-ptr gid_t)))
  1988. ;                          (:return-type int)
  1989. ;)
  1990.  
  1991. (def-c-call-out initgroups (:arguments (user c-string) (group gid_t))
  1992.                            (:return-type int)
  1993. )
  1994.  
  1995. ; ============================ <sys/utsname.h> ================================
  1996.  
  1997. (def-c-struct utsname
  1998.   (sysname (c-array-max character 65))
  1999.   (nodename (c-array-max character 65))
  2000.   (release (c-array-max character 65))
  2001.   (version (c-array-max character 65))
  2002.   (machine (c-array-max character 65))
  2003.   (domainname (c-array-max character 65))
  2004. )
  2005.  
  2006. (def-c-call-out uname (:arguments (utsbuf (c-ptr utsname) :out))
  2007.                       (:return-type int)
  2008. )
  2009.  
  2010. ; ============================= <termios.h> ===================================
  2011.  
  2012. ; --------------------------- <linux/termios.h> -------------------------------
  2013.  
  2014. (defconstant TCGETS     #x5401)
  2015. (defconstant TCSETS     #x5402)
  2016. (defconstant TCSETSW    #x5403)
  2017. (defconstant TCSETSF    #x5404)
  2018. (defconstant TCGETA     #x5405)
  2019. (defconstant TCSETA     #x5406)
  2020. (defconstant TCSETAW    #x5407)
  2021. (defconstant TCSETAF    #x5408)
  2022. (defconstant TCSBRK     #x5409)
  2023. (defconstant TCXONC     #x540A)
  2024. (defconstant TCFLSH     #x540B)
  2025. (defconstant TIOCEXCL   #x540C)
  2026. (defconstant TIOCNXCL   #x540D)
  2027. (defconstant TIOCSCTTY  #x540E)
  2028. (defconstant TIOCGPGRP  #x540F)
  2029. (defconstant TIOCSPGRP   #x5410)
  2030. (defconstant TIOCOUTQ    #x5411)
  2031. (defconstant TIOCSTI     #x5412)
  2032. (defconstant TIOCGWINSZ  #x5413)
  2033. (defconstant TIOCSWINSZ  #x5414)
  2034. (defconstant TIOCMGET    #x5415)
  2035. (defconstant TIOCMBIS    #x5416)
  2036. (defconstant TIOCMBIC    #x5417)
  2037. (defconstant TIOCMSET    #x5418)
  2038. (defconstant TIOCGSOFTCAR #x5419)
  2039. (defconstant TIOCSSOFTCAR #x541A)
  2040. (defconstant FIONREAD    #x541B)
  2041. (defconstant TIOCINQ     FIONREAD)
  2042. (defconstant TIOCLINUX   #x541C)
  2043. (defconstant TIOCCONS    #x541D)
  2044. (defconstant TIOCGSERIAL #x541E)
  2045. (defconstant TIOCSSERIAL #x541F)
  2046. (defconstant TIOCPKT     #x5420)
  2047. (defconstant FIONBIO     #x5421)
  2048. (defconstant TIOCNOTTY   #x5422)
  2049. (defconstant TIOCSETD    #x5423)
  2050. (defconstant TIOCGETD    #x5424)
  2051. (defconstant TCSBRKP     #x5425)
  2052. (defconstant TIOCTTYGSTRUCT #x5426)
  2053. (defconstant FIONCLEX    #x5450)
  2054. (defconstant FIOCLEX     #x5451)
  2055. (defconstant FIOASYNC    #x5452)
  2056. (defconstant TIOCSERCONFIG #x5453)
  2057. (defconstant TIOCSERGWILD  #x5454)
  2058. (defconstant TIOCSERSWILD  #x5455)
  2059. (defconstant TIOCGLCKTRMIOS #x5456)
  2060. (defconstant TIOCSLCKTRMIOS #x5457)
  2061. (defconstant TIOCSERGSTRUCT #x5458)
  2062. (defconstant TIOCSERGETLSR  #x5459)
  2063. (defconstant TIOCSERGETMULTI #x545A)
  2064. (defconstant TIOCSERSETMULTI #x545B)
  2065.  
  2066. (defconstant TIOCPKT_DATA       0)
  2067. (defconstant TIOCPKT_FLUSHREAD  1)
  2068. (defconstant TIOCPKT_FLUSHWRITE 2)
  2069. (defconstant TIOCPKT_STOP       4)
  2070. (defconstant TIOCPKT_START      8)
  2071. (defconstant TIOCPKT_NOSTOP    16)
  2072. (defconstant TIOCPKT_DOSTOP    32)
  2073.  
  2074. (def-c-struct winsize
  2075.   (ws_row ushort)
  2076.   (ws_col ushort)
  2077.   (ws_xpixel ushort)
  2078.   (ws_ypixel ushort)
  2079. )
  2080.  
  2081. (eval-when (load compile eval)
  2082.   (defconstant NCC 8)
  2083. )
  2084. (def-c-struct termio
  2085.   (c_iflag ushort)
  2086.   (c_oflag ushort)
  2087.   (c_cflag ushort)
  2088.   (c_lflag ushort)
  2089.   (c_line uchar)
  2090.   (c_cc (c-array uchar #.NCC))
  2091. )
  2092.  
  2093. (eval-when (load compile eval)
  2094.   (defconstant NCCS 19)
  2095. )
  2096. (def-c-struct termios
  2097.   (c_iflag tcflag_t)
  2098.   (c_oflag tcflag_t)
  2099.   (c_cflag tcflag_t)
  2100.   (c_lflag tcflag_t)
  2101.   (c_line cc_t)
  2102.   (c_cc (c-array cc_t #.NCCS))
  2103. )
  2104.  
  2105. ; c_cc characters
  2106. (defconstant VINTR 0)
  2107. (defconstant VQUIT 1)
  2108. (defconstant VERASE 2)
  2109. (defconstant VKILL 3)
  2110. (defconstant VEOF 4)
  2111. (defconstant VTIME 5)
  2112. (defconstant VMIN 6)
  2113. (defconstant VSWTC 7)
  2114. (defconstant VSTART 8)
  2115. (defconstant VSTOP 9)
  2116. (defconstant VSUSP 10)
  2117. (defconstant VEOL 11)
  2118. (defconstant VREPRINT 12)
  2119. (defconstant VDISCARD 13)
  2120. (defconstant VWERASE 14)
  2121. (defconstant VLNEXT 15)
  2122. (defconstant VEOL2 16)
  2123.  
  2124. ; c_iflag bits
  2125. (defconstant IGNBRK  #o000001)
  2126. (defconstant BRKINT  #o000002)
  2127. (defconstant IGNPAR  #o000004)
  2128. (defconstant PARMRK  #o000010)
  2129. (defconstant INPCK   #o000020)
  2130. (defconstant ISTRIP  #o000040)
  2131. (defconstant INLCR   #o000100)
  2132. (defconstant IGNCR   #o000200)
  2133. (defconstant ICRNL   #o000400)
  2134. (defconstant IUCLC   #o001000)
  2135. (defconstant IXON    #o002000)
  2136. (defconstant IXANY   #o004000)
  2137. (defconstant IXOFF   #o010000)
  2138. (defconstant IMAXBEL #o020000)
  2139.  
  2140. ; c_oflag bits
  2141. (defconstant OPOST   #o000001)
  2142. (defconstant OLCUC   #o000002)
  2143. (defconstant ONLCR   #o000004)
  2144. (defconstant OCRNL   #o000010)
  2145. (defconstant ONOCR   #o000020)
  2146. (defconstant ONLRET  #o000040)
  2147. (defconstant OFILL   #o000100)
  2148. (defconstant OFDEL   #o000200)
  2149. (defconstant NLDLY   #o000400)
  2150. (defconstant   NL0   #o000000)
  2151. (defconstant   NL1   #o000400)
  2152. (defconstant CRDLY   #o003000)
  2153. (defconstant   CR0   #o000000)
  2154. (defconstant   CR1   #o001000)
  2155. (defconstant   CR2   #o002000)
  2156. (defconstant   CR3   #o003000)
  2157. (defconstant TABDLY  #o014000)
  2158. (defconstant   TAB0  #o000000)
  2159. (defconstant   TAB1  #o004000)
  2160. (defconstant   TAB2  #o010000)
  2161. (defconstant   TAB3  #o014000)
  2162. (defconstant   XTABS #o014000)
  2163. (defconstant BSDLY   #o020000)
  2164. (defconstant   BS0   #o000000)
  2165. (defconstant   BS1   #o020000)
  2166. (defconstant VTDLY   #o040000)
  2167. (defconstant   VT0   #o000000)
  2168. (defconstant   VT1   #o040000)
  2169. (defconstant FFDLY   #o100000)
  2170. (defconstant   FF0   #o000000)
  2171. (defconstant   FF1   #o100000)
  2172.  
  2173. ; c_cflag bit meaning
  2174. (defconstant CBAUD   #o010017)
  2175. (defconstant  B0     #o000000)
  2176. (defconstant  B50    #o000001)
  2177. (defconstant  B75    #o000002)
  2178. (defconstant  B110   #o000003)
  2179. (defconstant  B134   #o000004)
  2180. (defconstant  B150   #o000005)
  2181. (defconstant  B200   #o000006)
  2182. (defconstant  B300   #o000007)
  2183. (defconstant  B600   #o000010)
  2184. (defconstant  B1200  #o000011)
  2185. (defconstant  B1800  #o000012)
  2186. (defconstant  B2400  #o000013)
  2187. (defconstant  B4800  #o000014)
  2188. (defconstant  B9600  #o000015)
  2189. (defconstant  B19200 #o000016)
  2190. (defconstant  B38400 #o000017)
  2191. (defconstant EXTA B19200)
  2192. (defconstant EXTB B38400)
  2193. (defconstant CSIZE   #o000060)
  2194. (defconstant   CS5   #o000000)
  2195. (defconstant   CS6   #o000020)
  2196. (defconstant   CS7   #o000040)
  2197. (defconstant   CS8   #o000060)
  2198. (defconstant CSTOPB  #o000100)
  2199. (defconstant CREAD   #o000200)
  2200. (defconstant PARENB  #o000400)
  2201. (defconstant PARODD  #o001000)
  2202. (defconstant HUPCL   #o002000)
  2203. (defconstant CLOCAL  #o004000)
  2204. (defconstant CBAUDEX #o010000)
  2205. (defconstant  B57600  #o010001)
  2206. (defconstant  B115200 #o010002)
  2207. (defconstant  B230400 #o010003)
  2208. (defconstant CIBAUD    #o02003600000)
  2209. (defconstant CRTSCTS   #o20000000000)
  2210.  
  2211. ; c_lflag bits
  2212. (defconstant ISIG    #o000001)
  2213. (defconstant ICANON  #o000002)
  2214. (defconstant XCASE   #o000004)
  2215. (defconstant ECHO    #o000010)
  2216. (defconstant ECHOE   #o000020)
  2217. (defconstant ECHOK   #o000040)
  2218. (defconstant ECHONL  #o000100)
  2219. (defconstant NOFLSH  #o000200)
  2220. (defconstant TOSTOP  #o000400)
  2221. (defconstant ECHOCTL #o001000)
  2222. (defconstant ECHOPRT #o002000)
  2223. (defconstant ECHOKE  #o004000)
  2224. (defconstant FLUSHO  #o010000)
  2225. (defconstant PENDIN  #o040000)
  2226. (defconstant IEXTEN  #o100000)
  2227.  
  2228. ; modem lines
  2229. (defconstant TIOCM_LE        #x001)
  2230. (defconstant TIOCM_DTR       #x002)
  2231. (defconstant TIOCM_RTS       #x004)
  2232. (defconstant TIOCM_ST        #x008)
  2233. (defconstant TIOCM_SR        #x010)
  2234. (defconstant TIOCM_CTS       #x020)
  2235. (defconstant TIOCM_CAR       #x040)
  2236. (defconstant TIOCM_RNG       #x080)
  2237. (defconstant TIOCM_DSR       #x100)
  2238. (defconstant TIOCM_CD        TIOCM_CAR)
  2239. (defconstant TIOCM_RI        TIOCM_RNG)
  2240.  
  2241. (defconstant TIOCSER_TEMT    #x01)
  2242.  
  2243. ; tcflow() and TCXONC use these
  2244. (defconstant TCOOFF          0)
  2245. (defconstant TCOON           1)
  2246. (defconstant TCIOFF          2)
  2247. (defconstant TCION           3)
  2248.  
  2249. ; tcflush() and TCFLSH use these
  2250. (defconstant TCIFLUSH        0)
  2251. (defconstant TCOFLUSH        1)
  2252. (defconstant TCIOFLUSH       2)
  2253.  
  2254. ; tcsetattr uses these
  2255. (defconstant TCSANOW         0)
  2256. (defconstant TCSADRAIN       1)
  2257. (defconstant TCSAFLUSH       2)
  2258.  
  2259. ; line disciplines
  2260. (defconstant N_TTY           0)
  2261. (defconstant N_SLIP          1)
  2262. (defconstant N_MOUSE         2)
  2263. (defconstant N_PPP           3)
  2264.  
  2265. ; ----------------------------- <termios.h> -----------------------------------
  2266.  
  2267. (def-c-call-out cfgetispeed (:arguments (termios_p (c-ptr termios)))
  2268.                             (:return-type speed_t)
  2269. )
  2270. (def-c-call-out cfgetospeed (:arguments (termios_p (c-ptr termios)))
  2271.                             (:return-type speed_t)
  2272. )
  2273.  
  2274. (def-c-call-out cfmakeraw (:arguments (t (c-ptr termios) :in-out))
  2275.                           (:return-type nil)
  2276. )
  2277.  
  2278. (def-c-call-out cfsetispeed (:arguments (termios_p (c-ptr termios) :in-out) (speed speed_t))
  2279.                             (:return-type int)
  2280. )
  2281. (def-c-call-out cfsetospeed (:arguments (termios_p (c-ptr termios) :in-out) (speed speed_t))
  2282.                             (:return-type int)
  2283. )
  2284.  
  2285. (def-c-call-out tcdrain (:arguments (fildes int))
  2286.                         (:return-type int)
  2287. )
  2288.  
  2289. (def-c-call-out tcflow (:arguments (fildes int) (action int))
  2290.                        (:return-type int)
  2291. )
  2292.  
  2293. (def-c-call-out tcflush (:arguments (fildes int) (queue_selector int))
  2294.                         (:return-type int)
  2295. )
  2296.  
  2297. (def-c-call-out tcgetpgrp (:arguments (fildes int))
  2298.                           (:return-type pid_t)
  2299. )
  2300.  
  2301. (def-c-call-out tcgetattr (:arguments (fildes int) (termios_p (c-ptr termios) :out))
  2302.                           (:return-type int)
  2303. )
  2304.  
  2305. (def-c-call-out tcsendbreak (:arguments (fildes int) (duration int))
  2306.                             (:return-type int)
  2307. )
  2308.  
  2309. (def-c-call-out tcsetattr (:arguments (fildes int) (optional_actions int) (termios_p (c-ptr termios)))
  2310.                           (:return-type int)
  2311. )
  2312.  
  2313. (def-c-call-out tcsetpgrp (:arguments (fildes int) (pgrp_id pid_t))
  2314.                           (:return-type int)
  2315. )
  2316.  
  2317.  
  2318. #|
  2319. ; ============================== <.h> ====================================
  2320. ; =============================================================================
  2321.  
  2322. (def-c-call-out (:arguments
  2323.                 (:return-type
  2324. )
  2325.  
  2326. (defconstant )
  2327. |#
  2328. ; =============================================================================
  2329. #| Not yet converted:
  2330.  
  2331. sys:
  2332. -rw-r--r--   1 bin      bin           786 Oct 18  1992 file.h
  2333. -rw-r--r--   1 bin      bin           261 Nov 17  1992 ioctl.h
  2334. -rw-r--r--   1 bin      bin           290 Mar  5  1994 ipc.h
  2335. -rw-r--r--   1 bin      bin            83 Jan  3  1993 kd.h
  2336. -rw-r--r--   1 bin      bin           533 Feb 15  1994 mman.h
  2337. -rw-r--r--   1 bin      bin           331 Jan 25  1993 mount.h
  2338. -rw-r--r--   1 bin      bin           495 Jun 19  1993 msg.h
  2339. -rw-r--r--   1 bin      bin           363 Nov 17  1992 mtio.h
  2340. -rw-r--r--   1 bin      bin           431 May  6  1993 param.h
  2341. -rw-r--r--   1 bin      bin           229 Oct 19  1992 ptrace.h
  2342. -rw-r--r--   1 bin      bin           676 Aug 17  1993 resource.h
  2343. -rw-r--r--   1 bin      bin           632 Jun 19  1993 sem.h
  2344. -rw-r--r--   1 bin      bin          2638 Oct  2  1992 serial.h
  2345. -rw-r--r--   1 bin      bin           406 Jun 19  1993 shm.h
  2346. -rw-r--r--   1 bin      bin            20 Oct  2  1992 signal.h
  2347. -rw-r--r--   1 bin      bin          4538 Jan 25  1993 socket.h
  2348. -rw-r--r--   1 bin      bin           421 Oct 18  1992 socketcall.h
  2349. -rw-r--r--   1 bin      bin            29 Oct 13  1993 socketio.h
  2350. -rw-r--r--   1 bin      bin            30 Dec 14  1993 soundcard.h
  2351. -rw-r--r--   1 bin      bin          3404 Jul 22  1994 syscall.h
  2352. -rw-r--r--   1 bin      bin          6679 Dec 12  1993 syslog.h
  2353. -rw-r--r--   1 bin      bin           186 Oct  5  1993 sysmacros.h
  2354. -rw-r--r--   1 bin      bin          2315 Oct 31  1993 time.h
  2355. -rw-r--r--   1 bin      bin           294 Oct 18  1992 timeb.h
  2356. -rw-r--r--   1 bin      bin           266 Oct 31  1993 times.h
  2357. -rw-r--r--   1 bin      bin           441 Oct 31  1993 timex.h
  2358. -rw-r--r--   1 bin      bin          1995 Jan 25  1993 uio.h
  2359. -rw-r--r--   1 bin      bin            30 Dec 14  1993 ultrasound.h
  2360. -rw-r--r--   1 bin      bin            22 Oct  2  1992 un.h
  2361. -rw-r--r--   1 bin      bin            24 Oct  2  1992 user.h
  2362. -rw-r--r--   1 bin      bin           408 Apr 11  1993 vfs.h
  2363. -rw-r--r--   1 bin      bin           183 Oct 18  1992 vm86.h
  2364. -rw-r--r--   1 bin      bin            83 Jan  3  1993 vt.h
  2365. -rw-r--r--   1 bin      bin          4920 Jul 24  1993 wait.h
  2366.  
  2367. .:
  2368. drwxr-xr-x   2 bin      bin          1024 Apr 18  1993 arpa
  2369. -rw-r--r--   1 bin      bin         11300 Aug  8  1993 curses.h
  2370. -rw-r--r--   1 bin      bin          1995 Oct  2  1992 dbm.h
  2371. -rw-r--r--   1 bin      bin          1755 Aug 14  1993 fnmatch.h
  2372. -rw-r--r--   1 bin      bin           255 Jan 11  1994 fpu_control.h
  2373. -rw-r--r--   1 bin      bin          1545 Jan 25  1993 ftw.h
  2374. -rw-r--r--   1 bin      bin          3571 Nov 29  1992 gdbm.h
  2375. -r--r--r--   1 bin      bin          4507 Jul 25  1993 getopt.h
  2376. -rw-r--r--   1 bin      bin          3350 Aug 14  1993 glob.h
  2377. -rw-r--r--   1 bin      bin          2581 Dec 11  1993 iolibio.h
  2378. -rw-r--r--   1 bin      bin          3294 Dec 11  1993 iostdio.h
  2379. -rw-r--r--   1 bin      bin           174 Mar 26  1994 lastlog.h
  2380. -rw-r--r--   1 bin      bin          7501 Dec 30  1993 libio.h
  2381. -rw-r--r--   1 bin      bin          3727 Dec 10  1993 locale.h
  2382. -rw-r--r--   1 bin      bin          5054 Feb 14  1994 localeinfo.h
  2383. -rw-r--r--   1 bin      bin            20 Oct  2  1992 memory.h
  2384. -rw-r--r--   1 bin      bin          1308 Feb 14  1994 mntent.h
  2385. -rw-r--r--   1 bin      bin          2462 Oct  2  1992 ndbm.h
  2386. drwxr-xr-x   2 bin      bin          1024 Oct 27  1993 net
  2387. -rw-r--r--   1 bin      bin          5149 Mar  2  1993 netdb.h
  2388. drwxr-xr-x   2 bin      bin          1024 Sep 25 18:45 netinet
  2389. -rw-r--r--   1 bin      bin          2039 Mar 23  1994 nl_types.h
  2390. -rw-r--r--   1 bin      bin          1425 Oct 12  1992 nlist.h
  2391. -rw-r--r--   1 bin      bin         19890 Feb 21  1994 obstack.h
  2392. -rw-r--r--   1 bin      bin          3239 Apr  4  1994 paths.h
  2393. drwxr-xr-x   2 bin      bin          1024 Apr 18  1993 protocols
  2394. -rwxr-xr-x   1 bin      bin         19352 Feb 12  1994 regex.h
  2395. -rw-r--r--   1 bin      bin          5128 Nov 16  1993 regexp.h
  2396. -rw-r--r--   1 bin      bin          5639 Mar 10  1993 resolv.h
  2397. drwxr-xr-x   2 bin      bin          1024 Apr 18  1993 rpc
  2398. drwxr-xr-x   2 bin      bin          1024 Mar 12  1993 rpcsvc
  2399. -rw-r--r--   1 bin      bin           382 Oct  2  1992 sharedlib.h
  2400. -rw-r--r--   1 bin      bin          3374 Nov 15  1993 signal.h
  2401. -rw-r--r--   1 bin      bin          7421 Dec 17  1993 string.h
  2402. -rw-r--r--   1 bin      bin            20 Oct  2  1992 strings.h
  2403. drwxr-xr-x   2 bin      bin          1024 May 15  1994 sys
  2404. -rw-r--r--   1 bin      bin           656 Mar  8  1994 syscall.h
  2405. -rw-r--r--   1 bin      bin          5458 May 11  1993 sysexits.h
  2406. -rw-r--r--   1 bin      bin            24 Nov  5  1992 syslog.h
  2407. -rw-r--r--   1 bin      bin          3747 Oct  5  1992 tar.h
  2408. -rw-r--r--   1 bin      bin          1831 Feb 10  1994 termcap.h
  2409. -rw-r--r--   1 bin      bin          1397 Nov 29  1993 time.h
  2410. -rw-r--r--   1 bin      bin           200 Apr 20  1993 ulimit.h
  2411. -rw-r--r--   1 bin      bin           264 Nov 19  1993 utime.h
  2412. -rw-r--r--   1 bin      bin          1456 Apr  4  1994 utmp.h
  2413. -rw-r--r--   1 bin      bin          1156 Mar 10  1994 waitflags.h
  2414. -rw-r--r--   1 bin      bin          3724 Jul 24  1993 waitstatus.h
  2415.  
  2416. arpa:
  2417. -rw-r--r--   1 bin      bin          3658 Mar 12  1993 ftp.h
  2418. -rw-r--r--   1 bin      bin          1778 Oct  2  1992 inet.h
  2419. -rw-r--r--   1 bin      bin          7802 Aug  6  1993 nameser.h
  2420. -rw-r--r--   1 bin      bin          9228 Jan 25  1994 telnet.h
  2421. -rw-r--r--   1 bin      bin          1973 Oct  2  1992 tftp.h
  2422.  
  2423. net:
  2424. -rw-r--r--   1 bin      bin            22 Mar  7  1993 if.h
  2425. -rw-r--r--   1 bin      bin            26 Mar  7  1993 if_arp.h
  2426. -rw-r--r--   1 bin      bin            28 Mar  7  1993 if_route.h
  2427.  
  2428. netinet:
  2429. -rw-r--r--   1 bin      bin          2663 May 29  1993 in.h
  2430. -rw-r--r--   1 bin      bin            28 Jul 26  1993 in_systm.h
  2431. -rw-r--r--   1 bin      bin            22 Jul 26  1993 ip.h
  2432. -rw-r--r--   1 bin      bin            24 Jan 25  1994 ip_icmp.h
  2433. -rw-r--r--   1 bin      bin          2022 Mar 10  1994 ip_tcp.h
  2434. -rw-r--r--   1 bin      bin            23 Jan 25  1994 ip_udp.h
  2435. -rw-r--r--   1 bin      bin          1328 Oct  2  1992 protocols.h
  2436. lrwxrwxrwx   1 bin      bin             8 Oct 27  1993 tcp.h -> ip_tcp.h
  2437. lrwxrwxrwx   1 bin      bin             8 Oct 27  1993 udp.h -> ip_udp.h
  2438.  
  2439. protocols:
  2440. -rw-r--r--   1 bin      bin          4887 Mar 12  1993 talkd.h
  2441. -rw-r--r--   1 bin      bin          3043 Oct  2  1992 timed.h
  2442.  
  2443. rpc:
  2444. -rw-r--r--   1 bin      bin          5140 Jan 27  1993 auth.h
  2445. -rw-r--r--   1 bin      bin          2589 Nov 20  1992 auth_unix.h
  2446. -rw-r--r--   1 bin      bin          9484 Mar  5  1993 clnt.h
  2447. -rw-r--r--   1 bin      bin          3390 Nov 20  1992 pmap_clnt.h
  2448. -rw-r--r--   1 bin      bin          3569 Oct 19  1992 pmap_prot.h
  2449. -rw-r--r--   1 bin      bin          2001 Oct 19  1992 pmap_rmt.h
  2450. -rw-r--r--   1 bin      bin          2846 Mar  5  1993 rpc.h
  2451. -rw-r--r--   1 bin      bin          4487 Oct 19  1992 rpc_msg.h
  2452. -rw-r--r--   1 bin      bin          9504 May 11  1993 svc.h
  2453. -rw-r--r--   1 bin      bin          1754 Oct 19  1992 svc_auth.h
  2454. -rw-r--r--   1 bin      bin          2173 Mar  5  1993 types.h
  2455. -rw-r--r--   1 bin      bin         11063 Nov 20  1992 xdr.h
  2456.  
  2457. rpcsvc:
  2458. -rw-r--r--   1 bin      bin          2823 Sep 21  1992 bootparam_prot
  2459. -rw-r--r--   1 bin      bin          2823 Mar  7  1993 bootparam_prot.x
  2460. -rw-r--r--   1 bin      bin          1490 Sep 21  1992 klm_prot.h
  2461. -rw-r--r--   1 bin      bin          3486 Mar  7  1993 klm_prot.x
  2462. -rw-r--r--   1 bin      bin          1512 Sep 21  1992 mount.h
  2463. -rw-r--r--   1 bin      bin          4365 Mar  7  1993 mount.x
  2464. -rw-r--r--   1 bin      bin          5914 Sep 21  1992 nfs_prot.h
  2465. -rw-r--r--   1 bin      bin          7684 Mar  7  1993 nfs_prot.x
  2466. -rw-r--r--   1 bin      bin          4049 Sep 21  1992 nlm_prot.h
  2467. -rw-r--r--   1 bin      bin          3476 Mar  7  1993 nlm_prot.x
  2468. -rw-r--r--   1 bin      bin          3383 Sep 21  1992 rex.h
  2469. -rw-r--r--   1 bin      bin          7115 Mar  7  1993 rex.x
  2470. -rw-r--r--   1 bin      bin           935 Sep 21  1992 rnusers.h
  2471. -rw-r--r--   1 bin      bin          2151 Mar  7  1993 rnusers.x
  2472. -rw-r--r--   1 bin      bin           983 Sep 21  1992 rquota.h
  2473. -rw-r--r--   1 bin      bin          1569 Mar  7  1993 rquota.x
  2474. -rw-r--r--   1 bin      bin          1889 Sep 21  1992 rstat.h
  2475. -rw-r--r--   1 bin      bin          3694 Mar  7  1993 rstat.x
  2476. -rw-r--r--   1 bin      bin          1269 Sep 21  1992 sm_inter.h
  2477. -rw-r--r--   1 bin      bin          3546 Mar  7  1993 sm_inter.x
  2478. -rw-r--r--   1 bin      bin           643 Sep 21  1992 spray.h
  2479. -rw-r--r--   1 bin      bin          2238 Mar  7  1993 spray.x
  2480. -rw-r--r--   1 bin      bin          5444 Sep 21  1992 yp.h
  2481. -rw-r--r--   1 bin      bin          6130 Mar  7  1993 yp.x
  2482. -rw-r--r--   1 bin      bin         10736 Aug 14  1993 yp_prot.h
  2483. -rw-r--r--   1 bin      bin          3222 Mar  5  1993 ypclnt.h
  2484. -rw-r--r--   1 bin      bin          3034 Mar  5  1993 yppasswd.h
  2485. |#
  2486.